@kabmo-labs/kabmo 0.33.0 → 0.34.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 (211) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +785 -624
  3. package/dist/client/static/js/{CsvGrid-fncjbg6j.js → CsvGrid-vze4m5ag.js} +1 -1
  4. package/dist/client/static/js/{DocxView-c9v2vr3r.js → DocxView-jbf21gmh.js} +5 -5
  5. package/dist/client/static/js/{DrawioView-vxjksm12.js → DrawioView-b52qybx5.js} +2 -2
  6. package/dist/client/static/js/{ImageView-a3g5k226.js → ImageView-mdgzj8px.js} +1 -1
  7. package/dist/client/static/js/{LayoutWrapper-hnjfwsjh.js → LayoutWrapper-3c49dvtt.js} +2 -2
  8. package/dist/client/static/js/Modal-sqp864vd.js +38 -0
  9. package/dist/client/static/js/{PdfView-ksaes53y.js → PdfView-g06rxqb1.js} +1 -1
  10. package/dist/client/static/js/{SessionsView-30vcr95v.js → SessionsView-521adxyr.js} +1 -1
  11. package/dist/client/static/js/{SheetView-vc484scg.js → SheetView-h8xmsz7q.js} +22 -22
  12. package/dist/client/static/js/{SvgPreview-tph89jet.js → SvgPreview-1j4jvcvz.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-xbar278c.js → abnfDiagram-O67JEVCF-pasxh4b6.js} +1 -1
  14. package/dist/client/static/js/architecture-7GRP2DOG-fc9kmq1w.js +1 -0
  15. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-s171n2z6.js → architectureDiagram-NJMV4G6O-ms14g0bm.js} +4 -4
  16. package/dist/client/static/js/{blockDiagram-BEXU5L5S-gzx6rv9n.js → blockDiagram-BEXU5L5S-ycn78fcq.js} +4 -4
  17. package/dist/client/static/js/{c4Diagram-YGBWAQC7-7f00skch.js → c4Diagram-YGBWAQC7-vn2gpjfm.js} +5 -5
  18. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-j79v95nc.js → classDiagram-v2-NBCMYWYE-fyrm1pr5.js} +4 -4
  19. package/dist/client/static/js/{cose-bilkent-JH36ORCC-5fkn7ee5.js → cose-bilkent-JH36ORCC-ea5nwvgq.js} +1 -1
  20. package/dist/client/static/js/cynefin-OW5HDTMX-a4t8992q.js +1 -0
  21. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-cfs1yvrd.js → cynefinDiagram-VND7K2PF-j6bsjpre.js} +1 -1
  22. package/dist/client/static/js/{dagre-6A5THRUB-44bgc48p.js → dagre-6A5THRUB-4smdkwv8.js} +2 -2
  23. package/dist/client/static/js/{diagram-22UHCM2B-a4g4x83k.js → diagram-22UHCM2B-9sm4kqwc.js} +11 -11
  24. package/dist/client/static/js/{diagram-3UASUU5V-gm4rg5na.js → diagram-3UASUU5V-2h3qxaed.js} +1 -1
  25. package/dist/client/static/js/{diagram-ATOU4E4O-a95y41vk.js → diagram-ATOU4E4O-1981bc94.js} +3 -3
  26. package/dist/client/static/js/{diagram-CDSNMT55-t3j93mmc.js → diagram-CDSNMT55-3vgsxavc.js} +4 -4
  27. package/dist/client/static/js/{diagram-MLGK6HIB-c2wdez02.js → diagram-MLGK6HIB-c9gf2r3f.js} +2 -2
  28. package/dist/client/static/js/{diagram-MPIPVDR6-gya9jhs5.js → diagram-MPIPVDR6-gjqeq92d.js} +2 -2
  29. package/dist/client/static/js/{dockerfile-a7q6174s.js → dockerfile-8v935dkn.js} +1 -1
  30. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-jjhkza6t.js → ebnfDiagram-ZINNZB2B-4vbsgh99.js} +1 -1
  31. package/dist/client/static/js/{elixir-rpa1g4gy.js → elixir-vcbg60wv.js} +1 -1
  32. package/dist/client/static/js/{elk-276RUBZZ-f7re45mw.js → elk-276RUBZZ-nca3t891.js} +1 -1
  33. package/dist/client/static/js/{erDiagram-OPXOYQCR-tpm9g5te.js → erDiagram-OPXOYQCR-5kfkev03.js} +2 -2
  34. package/dist/client/static/js/eventmodeling-NTZA5JFV-18bdrkv5.js +1 -0
  35. package/dist/client/static/js/flowDiagram-KWPJA3E3-fg0yqx0h.js +1 -0
  36. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-fz43n12d.js → ganttDiagram-FUAMR5RP-mxc73wmq.js} +3 -3
  37. package/dist/client/static/js/gitGraph-4MIJSDKK-8fa6y40p.js +1 -0
  38. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-f61hgbn6.js → gitGraphDiagram-X574FWY7-7en3ag0e.js} +12 -12
  39. package/dist/client/static/js/html-dbrwss36.js +1 -0
  40. package/dist/client/static/js/{index-m73za75e.js → index-0vm41je9.js} +3 -3
  41. package/dist/client/static/js/{index-eyzeya95.js → index-1b0t1428.js} +5 -5
  42. package/dist/client/static/js/{index-2x5f66t6.js → index-1ksg88qf.js} +1 -1
  43. package/dist/client/static/js/{index-sffjtm5w.js → index-231241f4.js} +9 -9
  44. package/dist/client/static/js/index-2mx9ej4k.css +1 -0
  45. package/dist/client/static/js/{index-8239j2v1.js → index-4g46wbdw.js} +1 -1
  46. package/dist/client/static/js/{index-1xqs14fr.js → index-4qwzxj81.js} +1 -1
  47. package/dist/client/static/js/{index-gcs49f3p.js → index-52rqxgya.js} +1 -1
  48. package/dist/client/static/js/{index-at6bhjyf.js → index-6sf2vsp2.js} +1 -1
  49. package/dist/client/static/js/{index-q2w6s8n7.js → index-7a64yjrm.js} +4 -4
  50. package/dist/client/static/js/{index-rg8jpbsw.js → index-8acv5b77.js} +2 -2
  51. package/dist/client/static/js/{index-js7t1vb1.js → index-a0fmsv1d.js} +5 -5
  52. package/dist/client/static/js/{index-w0fwb80e.js → index-ag2rmtas.js} +1 -1
  53. package/dist/client/static/js/{index-djmg1d7h.js → index-b29afsjh.js} +1 -1
  54. package/dist/client/static/js/{index-e4p4cd3r.js → index-c3ek61zv.js} +1 -1
  55. package/dist/client/static/js/{index-0e40xskg.js → index-cd65zqba.js} +1 -1
  56. package/dist/client/static/js/{index-zt75xpq0.js → index-cgzrpvzj.js} +204 -204
  57. package/dist/client/static/js/{index-0n5wwe60.js → index-ev3yt353.js} +2 -2
  58. package/dist/client/static/js/{index-9y3gjdj7.js → index-eyfcm0cy.js} +1 -1
  59. package/dist/client/static/js/{index-qsm2z36d.js → index-f7jhhqtk.js} +1 -1
  60. package/dist/client/static/js/{index-vw5k8csz.js → index-fta1y9pc.js} +50 -50
  61. package/dist/client/static/js/{index-ajs3jj6j.js → index-fvmfge3p.js} +1 -1
  62. package/dist/client/static/js/{index-pxv2nw9w.js → index-g2dyfze9.js} +1 -1
  63. package/dist/client/static/js/{index-bkye8mz4.js → index-h5bn97p6.js} +1 -1
  64. package/dist/client/static/js/{index-trm9x02n.js → index-j51d5a5m.js} +6 -6
  65. package/dist/client/static/js/{index-pbe4yed4.js → index-jsyekbx9.js} +2 -2
  66. package/dist/client/static/js/{index-gs6f0qwa.js → index-nccwxv0s.js} +2 -2
  67. package/dist/client/static/js/{index-d495kfm0.js → index-p0nz38bm.js} +1 -1
  68. package/dist/client/static/js/{index-sdtye3jy.js → index-pm6xxwz1.js} +2 -2
  69. package/dist/client/static/js/{index-3rcjx70v.js → index-ptcrwswj.js} +1 -1
  70. package/dist/client/static/js/{index-14vndmcr.js → index-ptcwae2n.js} +1 -1
  71. package/dist/client/static/js/{index-5tgq7aqx.js → index-r014brzs.js} +2 -2
  72. package/dist/client/static/js/{index-xj9649ac.js → index-ray2czf6.js} +7 -7
  73. package/dist/client/static/js/{index-apvkd37e.js → index-rs80cwsv.js} +3 -3
  74. package/dist/client/static/js/{index-vw4brsdx.js → index-rzxcj7cg.js} +1 -1
  75. package/dist/client/static/js/{index-a293pdg7.js → index-s7gkkkyz.js} +2 -2
  76. package/dist/client/static/js/{index-1a0zkj8h.js → index-sd66wv26.js} +2 -2
  77. package/dist/client/static/js/{index-ypx3qmhq.js → index-vhqe0y82.js} +1 -1
  78. package/dist/client/static/js/{index-9fjt5anh.js → index-vy6termr.js} +1 -1
  79. package/dist/client/static/js/{index-0tf0arsp.js → index-xx6mqpxm.js} +3 -3
  80. package/dist/client/static/js/{index-03h3bkcf.js → index-ybm2x4vh.js} +1 -1
  81. package/dist/client/static/js/info-A6RAGUB7-3hk844f7.js +1 -0
  82. package/dist/client/static/js/{infoDiagram-VRGFBTTK-1qj804sn.js → infoDiagram-VRGFBTTK-sef80132.js} +2 -2
  83. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-4j4qsnzw.js → ishikawaDiagram-OU5B5YK6-yhvepp1q.js} +6 -6
  84. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-j0brnfft.js → journeyDiagram-ZHPQQLJL-5w77y95w.js} +5 -5
  85. package/dist/client/static/js/{julia-4ghmfy3e.js → julia-d4j6wgvf.js} +1 -1
  86. package/dist/client/static/js/{kanban-definition-PNTS6WVX-qqc22br0.js → kanban-definition-PNTS6WVX-02znqtna.js} +6 -6
  87. package/dist/client/static/js/{mermaid.core-vv3wbe65.js → mermaid.core-a6e6vck4.js} +5 -5
  88. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-y5b2z8zp.js → mindmap-definition-NLK3R4M7-y4n74q9x.js} +8 -8
  89. package/dist/client/static/js/one-dark-pro-vwhfpzr8.js +1 -0
  90. package/dist/client/static/js/one-light-y5t9x6zh.js +1 -0
  91. package/dist/client/static/js/packet-AYTQ26CC-4nj2yy10.js +1 -0
  92. package/dist/client/static/js/{pegDiagram-GJSIUBJH-0be07mqs.js → pegDiagram-GJSIUBJH-pr7ehgzb.js} +1 -1
  93. package/dist/client/static/js/{perl-sd00t4b4.js → perl-srptw5vm.js} +1 -1
  94. package/dist/client/static/js/{php-2zfyqa61.js → php-n89g3fk7.js} +1 -1
  95. package/dist/client/static/js/pie-WAS4IAKB-k7rde3f9.js +1 -0
  96. package/dist/client/static/js/{pieDiagram-5QR66LMP-544w86jk.js → pieDiagram-5QR66LMP-39wpsk08.js} +2 -2
  97. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-p09e7z5s.js → quadrantDiagram-O4NWA36T-esm913km.js} +5 -5
  98. package/dist/client/static/js/radar-RG4KPBEZ-513dpw4f.js +1 -0
  99. package/dist/client/static/js/railroad-74A4TZTK-9bqnst9c.js +1 -0
  100. package/dist/client/static/js/railroad-abnf-HS5TGJTU-7367d5bv.js +1 -0
  101. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-b806b1mj.js +1 -0
  102. package/dist/client/static/js/railroad-peg-WCYAUIDC-5a67rwf8.js +1 -0
  103. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-de830ed2.js → railroadDiagram-XR7U4H2S-wy2mgya6.js} +1 -1
  104. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-b47d74p1.js → requirementDiagram-PLB6GJNP-6z9xdgbq.js} +2 -2
  105. package/dist/client/static/js/{ruby-v9qaqhby.js → ruby-r81ytgcm.js} +1 -1
  106. package/dist/client/static/js/{rust-fkt0qyrs.js → rust-frn3szvc.js} +1 -1
  107. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-6ezc2fpj.js → sankeyDiagram-IPEJSGJF-rtmxk3ys.js} +4 -4
  108. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-by5zqj6w.js → sequenceDiagram-PO4LG4MO-awzcrafg.js} +18 -18
  109. package/dist/client/static/js/{sizeCapture-INFHLROL-q85r06j6.js → sizeCapture-INFHLROL-03gy196j.js} +1 -1
  110. package/dist/client/static/js/sql-0e9mnrda.js +1 -0
  111. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-ep5pyexs.js → stateDiagram-v2-GCMORJYK-an8v3q5n.js} +3 -3
  112. package/dist/client/static/js/{swimlanes-2SLR337P-95fcqkh8.js → swimlanes-2SLR337P-n9yb4wcs.js} +1 -1
  113. package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-xs2en5dv.js → swimlanesDiagram-TC7HE7FX-nx5nfnf0.js} +1 -1
  114. package/dist/client/static/js/{timeline-definition-EJHVYXUP-461e615g.js → timeline-definition-EJHVYXUP-jceb575g.js} +4 -4
  115. package/dist/client/static/js/treeView-Q6P3EWNA-kcy40evb.js +1 -0
  116. package/dist/client/static/js/treemap-WGGIJYW6-fsrvqxf4.js +1 -0
  117. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-ftqfnvhg.js → usecaseDiagram-POWQR4AR-888h3100.js} +13 -13
  118. package/dist/client/static/js/{vennDiagram-UO4OBE2U-7t96h6ez.js → vennDiagram-UO4OBE2U-wbfz0rzv.js} +7 -7
  119. package/dist/client/static/js/{vue-j8vb9d7r.js → vue-c0rtg1wf.js} +1 -1
  120. package/dist/client/static/js/wardley-WFR3VGLG-36dmxww4.js +1 -0
  121. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-0de8w8c6.js → wardleyDiagram-VNRHLVJA-rn8c5qf9.js} +4 -4
  122. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-dez9phkf.js → xychartDiagram-PMCCYNJV-8sn1apt6.js} +5 -5
  123. package/package.json +4 -1
  124. package/src/client/components/auth/login-screen/index.tsx +1 -0
  125. package/src/client/components/common/MarkdownRenderer.tsx +9 -12
  126. package/src/client/components/settings/Modal.tsx +14 -84
  127. package/src/client/components/settings/Sidebar.tsx +3 -1
  128. package/src/client/components/settings/categories/ConnectSettings.tsx +105 -0
  129. package/src/client/components/settings/categories/connect-settings/DeviceTable.tsx +145 -0
  130. package/src/client/components/settings/categories/connect-settings/PairDialog.tsx +160 -0
  131. package/src/client/components/settings/categories/connect-settings/QrCode.tsx +73 -0
  132. package/src/client/components/settings/categories/connect-settings/ServerCard.tsx +94 -0
  133. package/src/client/components/settings/categories/connect-settings/TunnelRow.tsx +127 -0
  134. package/src/client/components/settings/category-content.tsx +116 -0
  135. package/src/client/components/workspace/chat-timeline/ChangedFilesSummary.test.tsx +120 -0
  136. package/src/client/components/workspace/chat-timeline/ChangedFilesSummary.tsx +56 -20
  137. package/src/client/components/workspace/chat-timeline/RunFooter.tsx +1 -0
  138. package/src/client/hooks/chat/timeline/change-stats.ts +57 -0
  139. package/src/client/hooks/connect/use-connect-status.ts +116 -0
  140. package/src/client/hooks/connect/use-pairing.ts +100 -0
  141. package/src/client/hooks/ui/clipboard.ts +26 -0
  142. package/src/client/tailwind.css +5 -0
  143. package/src/server/index.ts +2 -0
  144. package/src/server/lib/assets/font-css.server.test.ts +19 -0
  145. package/src/server/lib/auth/client-address.test.ts +58 -0
  146. package/src/server/lib/auth/client-address.ts +37 -3
  147. package/src/server/lib/auth/guard.ts +31 -4
  148. package/src/server/lib/auth/rate-limit.test.ts +25 -8
  149. package/src/server/lib/auth/rate-limit.ts +8 -5
  150. package/src/server/lib/connect/cloudflared.lifecycle.test.ts +88 -0
  151. package/src/server/lib/connect/cloudflared.server.test.ts +65 -0
  152. package/src/server/lib/connect/cloudflared.server.ts +206 -0
  153. package/src/server/lib/connect/devices.server.ts +192 -0
  154. package/src/server/lib/connect/identity.server.ts +81 -0
  155. package/src/server/lib/connect/pairing.server.test.ts +56 -0
  156. package/src/server/lib/connect/pairing.server.ts +113 -0
  157. package/src/server/lib/connect/qr.roundtrip.test.ts +106 -0
  158. package/src/server/lib/connect/qr.server.ts +36 -0
  159. package/src/server/lib/connect/run.server.ts +101 -0
  160. package/src/server/lib/connect/status.server.ts +177 -0
  161. package/src/server/lib/connect/tailscale.server.test.ts +117 -0
  162. package/src/server/lib/connect/tailscale.server.ts +172 -0
  163. package/src/server/lib/db/schema.ts +4 -0
  164. package/src/server/lib/omp/session/changes.test.ts +64 -1
  165. package/src/server/lib/omp/session/changes.ts +94 -1
  166. package/src/server/routes/connect/devices.ts +56 -0
  167. package/src/server/routes/connect/index.ts +15 -0
  168. package/src/server/routes/connect/pair-page.ts +177 -0
  169. package/src/server/routes/connect/pair.ts +158 -0
  170. package/src/server/routes/connect/status.ts +19 -0
  171. package/src/server/routes/connect/tunnels.ts +76 -0
  172. package/src/server/routes/health/probe.ts +5 -0
  173. package/src/server/routes/index.ts +2 -0
  174. package/src/server/routes/sessions/changes.test.ts +12 -3
  175. package/src/server/routes/sessions/changes.ts +27 -3
  176. package/src/server/routes/sessions/index.ts +2 -1
  177. package/src/shared/lib/connect/payload.test.ts +144 -0
  178. package/src/shared/lib/connect/payload.ts +229 -0
  179. package/src/shared/lib/connect/tier.test.ts +73 -0
  180. package/src/shared/lib/connect/tier.ts +105 -0
  181. package/src/shared/lib/connect/types.ts +99 -0
  182. package/src/shared/lib/markdown/fira-code-fonts.css +65 -6
  183. package/src/shared/lib/markdown/marked.ts +7 -4
  184. package/src/shared/lib/markdown/mermaid-actions.test.ts +78 -0
  185. package/src/shared/lib/markdown/mermaid-actions.ts +45 -0
  186. package/src/shared/lib/markdown/mermaid.ts +41 -7
  187. package/src/shared/lib/settings/sections.ts +6 -1
  188. package/src/shared/types/session-changes.ts +6 -0
  189. package/src/shared/types/settings/state.ts +2 -0
  190. package/dist/client/static/js/Modal-qtftcp2t.js +0 -38
  191. package/dist/client/static/js/architecture-7GRP2DOG-tavtgb8a.js +0 -1
  192. package/dist/client/static/js/cynefin-OW5HDTMX-cdh3n2z2.js +0 -1
  193. package/dist/client/static/js/eventmodeling-NTZA5JFV-as97tpyp.js +0 -1
  194. package/dist/client/static/js/flowDiagram-KWPJA3E3-ggm06d12.js +0 -1
  195. package/dist/client/static/js/gitGraph-4MIJSDKK-eqz7p9ng.js +0 -1
  196. package/dist/client/static/js/html-pv88ny12.js +0 -1
  197. package/dist/client/static/js/index-e94a1en0.css +0 -1
  198. package/dist/client/static/js/info-A6RAGUB7-4pkzh1qx.js +0 -1
  199. package/dist/client/static/js/one-dark-pro-hm3f56n1.js +0 -1
  200. package/dist/client/static/js/one-light-xrz49rct.js +0 -1
  201. package/dist/client/static/js/packet-AYTQ26CC-yg71sp88.js +0 -1
  202. package/dist/client/static/js/pie-WAS4IAKB-89wd6np0.js +0 -1
  203. package/dist/client/static/js/radar-RG4KPBEZ-avn0b8r9.js +0 -1
  204. package/dist/client/static/js/railroad-74A4TZTK-de27xv5w.js +0 -1
  205. package/dist/client/static/js/railroad-abnf-HS5TGJTU-rg4zzj7x.js +0 -1
  206. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-d84fhj8v.js +0 -1
  207. package/dist/client/static/js/railroad-peg-WCYAUIDC-dvf8xrmc.js +0 -1
  208. package/dist/client/static/js/sql-g8wcshpc.js +0 -1
  209. package/dist/client/static/js/treeView-Q6P3EWNA-mham0bh6.js +0 -1
  210. package/dist/client/static/js/treemap-WGGIJYW6-mxrxax86.js +0 -1
  211. package/dist/client/static/js/wardley-WFR3VGLG-8vrvh9p3.js +0 -1
@@ -1 +1 @@
1
- import{d,n,i,o,a,e,S,m,U,Vt,pa,De,C,Dn,y,og,Fp,Ru,sg,Wl}from"./index-zt75xpq0.js";import{cu}from"./index-e4p4cd3r.js";import"./index-9fjt5anh.js";var de={idle:"Kosong",loading:"Memuat",ready:"Siap"},V="p-1 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink cursor-pointer disabled:cursor-not-allowed transition-colors";function K({url:t,input:s,loading:r,error:l,canGoBack:p,canGoForward:f,viewportMode:h,zoomLevel:c,onInputChange:b,onSubmit:A,onBack:M,onForward:T,onReload:w,onOpenExternal:E,onIncludeInChat:I,onChangeViewport:R,onZoomIn:N,onZoomOut:L,onResetZoom:u,onSetZoom:g,annotate:k}){let x=o(void 0);i(()=>{if(x.current===t)return;if(x.current=t,t)b(t)},[t,b]);let B=!t?"idle":r?"loading":"ready",O=B==="ready"?"bg-success animate-pulse":B==="loading"?"bg-ink/40 animate-pulse":"bg-ink/25",D=e("div",{className:"flex items-center bg-canvas border border-ink/10 rounded-md p-0.5 space-x-0.5 flex-shrink-0",children:[e("button",{type:"button",onClick:M,disabled:!p,"aria-label":"Back",title:"Back",className:V,children:e(Vt,{size:12})}),e("button",{type:"button",onClick:T,disabled:!f,"aria-label":"Maju",title:"Maju",className:V,children:e(pa,{size:12})}),e("button",{type:"button",onClick:w,disabled:!t,"aria-label":"Reload",title:"Reload",className:V,children:e(C,{size:12,className:r?"animate-spin":void 0})})]});return e(cu,{url:t,statusDotClass:O,statusLabel:de[B],viewportMode:h,zoomLevel:c,onChangeViewport:R,onZoomIn:N,onZoomOut:L,onResetZoom:u,onSetZoom:g,annotate:k,onIncludeInChat:I,onOpenExternal:E,openExternalLabel:"Buka di tab baru",openExternalTitle:"Buka di tab baru (untuk situs yang menolak iframe)",children:e("div",{className:"flex items-center flex-1 min-w-0 space-x-1.5",children:[D,e("form",{className:`flex-1 min-w-0 flex items-center bg-canvas border rounded-md px-2 py-0.5 space-x-1 focus-within:border-ink/40 ${l?"border-error":"border-ink/15"}`,onSubmit:(v)=>{v.preventDefault(),A(s)},children:[e(De,{size:12,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:s,onChange:(v)=>b(v.currentTarget.value),placeholder:"Type an address (e.g. localhost:5173) and press Enter…","aria-label":"Browser address","aria-invalid":l!==void 0&&l!==null,title:l??void 0,spellcheck:!1,autoComplete:"off",className:`w-full min-w-0 bg-transparent outline-none font-mono text-[11px] placeholder:text-ink/35 ${l?"text-error":"text-ink/90"}`})]})]})})}var Z={"desktop-16-9":"w-full max-w-[1280px] aspect-video max-h-full border border-ink/20 rounded-lg shadow-md overflow-hidden my-auto",laptop:"w-[1024px] max-w-full h-[768px] max-h-full border border-ink/20 rounded-lg shadow-md overflow-hidden my-auto",tablet:"w-[768px] max-w-full h-[1024px] max-h-full border border-ink/20 rounded-lg shadow-md overflow-hidden my-auto",mobile:"w-[375px] max-w-full h-[667px] max-h-full border border-ink/20 rounded-xl shadow-md overflow-hidden my-auto","mobile-lg":"w-[414px] max-w-full h-[896px] max-h-full border border-ink/20 rounded-xl shadow-md overflow-hidden my-auto",responsive:"w-full h-full border-0"};var ce="clipboard-read; clipboard-write; fullscreen";function X({url:t,frameKey:s,loading:r,viewportMode:l,zoomLevel:p,onLoad:f,active:h=!0,overlay:c,onFrame:b}){if(!h)return null;if(!t)return e("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-center select-none",children:[e("div",{className:"w-12 h-12 rounded-xl bg-ink/5 border border-ink/10 flex items-center justify-center text-ink/40 mb-3",children:e(De,{size:22})}),e("h3",{className:"text-sm font-semibold text-ink mb-1",children:"Browser Anda"}),e("p",{className:"text-xs text-ink/60 max-w-sm",children:"Type an address above and press Enter. The page loads inside this panel."}),e("p",{className:"text-[11px] text-ink/45 max-w-sm mt-2",children:"Sebagian situs (Google, GitHub) menolak ditampilkan dalam iframe — pakai tombol buka di tab baru."})]});return e("div",{className:"flex-1 min-h-0 relative flex items-center justify-center p-2 overflow-auto bg-canvas/60",children:[r?e("div",{className:"absolute inset-0 z-10 flex items-center justify-center pointer-events-none",children:e("div",{className:"flex items-center space-x-2 px-3 py-1.5 rounded-md bg-paper border border-ink/15",children:[e(m,{size:13,className:"animate-spin text-ink/50"}),e("span",{className:"text-[11px] font-mono text-ink/60",children:"Memuat…"})]})}):null,e("div",{className:`relative flex flex-col bg-white ${Z[l]} transition-all duration-200`,style:{zoom:p!==100?`${p}%`:void 0,transformOrigin:"top center"},children:[e("iframe",{ref:(A)=>b?.(A),src:t,title:"Browser pengguna",onLoad:f,referrerPolicy:"no-referrer",allow:ce,className:"w-full h-full bg-white border-0",style:c?{pointerEvents:"none"}:void 0},s),c]})]})}var W="w-full min-w-0 bg-canvas border border-ink/15 rounded px-2 py-1 text-[11px] font-mono text-ink placeholder:text-ink/35 focus:outline-none focus:border-ink/40";function ue(t){if(!t||t.ok)return null;if(t.reason==="cross-origin")return"This page is cross-origin, so its elements cannot be read. Name the part and add a note instead.";if(t.reason==="no-frame")return"The page has not loaded, so its elements cannot be read yet.";return"There is no element at this point (empty space). Name the part instead."}function Y({shape:t,index:s,readability:r,onLabel:l,onNote:p}){let f=ue(r),h=t.element;return e("div",{className:"flex items-start gap-1.5 min-w-0",children:[e("span",{className:"text-[11px] font-mono text-ink/45 pt-1 flex-shrink-0",children:[Ru[t.tool]," #",s]}),e("div",{className:"flex-1 min-w-0 space-y-1",children:[e("div",{className:"flex items-center gap-1 flex-wrap",children:[e("span",{className:"text-[10px] uppercase font-mono text-ink/40",children:"bagian"}),sg.map((c)=>{let b=t.label===c;return e("button",{type:"button",onClick:()=>l(b?"":c),"aria-pressed":b,className:`px-1.5 py-0.5 rounded-full border text-[10px] font-mono transition-colors cursor-pointer ${b?"bg-ink text-canvas border-ink":"bg-canvas text-ink/65 border-ink/15 hover:border-ink/40"}`,children:c},c)}),e("input",{value:t.label,onInput:(c)=>l(c.currentTarget.value),placeholder:"or type your own…","aria-label":"Name of the marked part",spellcheck:!1,className:`${W} flex-1 min-w-[110px]`})]}),e("textarea",{value:t.note,onInput:(c)=>p(c.currentTarget.value),placeholder:"What is wrong with this part? (e.g. the Pay button looks disabled)",rows:2,"aria-label":"Annotation note",className:`${W} resize-y`}),h?e("p",{className:"text-[10px] font-mono text-ink/45 truncate",title:h.path,children:["elemen: ",h.path,h.state?` · ${h.state}`:""]}):null,f?e("p",{className:"text-[10px] text-ink/40",children:f}):null]})]})}var me=["box","pin","arrow"],pe="px-2 py-1 rounded text-[11px] font-mono border transition-colors cursor-pointer",F="flex items-center gap-1 px-2 py-1 rounded text-[11px] border border-ink/15 hover:border-ink/40 text-ink/80 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed";function j({tool:t,shapes:s,selectedId:r,readability:l,onTool:p,onLabel:f,onNote:h,onRemove:c,onReset:b,onCancel:A,onSend:M}){let T=s.find((E)=>E.id===r)??null,w=s.length>0;return e("div",{className:"flex-shrink-0 border-b border-ink/10 bg-paper px-2.5 py-1.5 space-y-1.5 select-none",children:[e("div",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-[10px] uppercase font-mono text-ink/50 mr-1",children:"Anotasi"}),me.map((E)=>e("button",{type:"button",onClick:()=>p(E),"aria-pressed":t===E,className:`${pe} ${t===E?"bg-ink text-canvas border-ink":"bg-canvas text-ink/70 border-ink/15 hover:border-ink/40"}`,children:Ru[E]},E)),e("span",{className:"text-[11px] font-mono text-ink/45 ml-1",children:s.length>0?`${s.length} mark${s.length===1?"":"s"}`:"drag on the page to mark a part"}),e("div",{className:"flex-1"}),e("button",{type:"button",onClick:b,disabled:!w,className:F,title:"Clear all marks",children:[e(U,{size:12})," Bersihkan"]}),e("button",{type:"button",onClick:M,disabled:!w,className:F,title:"Kirim anotasi ke draft chat",children:[e(Dn,{size:12})," Kirim ke chat"]}),e("button",{type:"button",onClick:A,className:F,title:"Tutup mode anotasi",children:e(y,{size:12})})]}),T?e("div",{className:"flex items-start gap-1.5",children:[e("div",{className:"flex-1 min-w-0",children:e(Y,{shape:T,index:s.indexOf(T)+1,readability:l,onLabel:(E)=>f(T.id,E),onNote:(E)=>h(T.id,E)})}),e("button",{type:"button",onClick:()=>c(T.id),className:F,title:"Remove this mark",children:e(U,{size:12})})]}):e("p",{className:"text-[11px] text-ink/45",children:"This page cannot be screenshotted, so what gets sent is the area, the part name and your note."})]})}var q=0;function J(){return q+=1,`annot-${Date.now().toString(36)}-${q}`}function Q(t){let[s,r]=n(!1),[l,p]=n("box"),[f,h]=n([]),[c,b]=n(null);i(()=>{h([]),b(null)},[t]);let A=a(()=>{r((N)=>!N),b(null)},[]),M=a(()=>{b(null),r(!1)},[]),T=a((N)=>{h((L)=>[...L,N]),b(N.id)},[]),w=a((N,L)=>{h((u)=>u.map((g)=>g.id===N?{...g,note:L}:g))},[]),E=a((N,L)=>{h((u)=>u.map((g)=>g.id===N?{...g,label:L}:g))},[]),I=a((N)=>{h((L)=>L.filter((u)=>u.id!==N)),b((L)=>L===N?null:L)},[]),R=a(()=>{h([]),b(null)},[]);return{active:s,tool:l,shapes:f,selectedId:c,setTool:p,toggle:A,close:M,add:T,setNote:w,setLabel:E,select:b,remove:I,reset:R}}var fe=4,_="var(--theme-error)";function ee({shapes:t,tool:s,selectedId:r,onMeasure:l,onAdd:p,onSelect:f}){let h=o(null),c=o(null),[b,A]=n(null),[M,T]=n({width:0,height:0});i(()=>{let u=h.current;if(!u)return;let g=()=>{let x=u.getBoundingClientRect();if(x.width<=0||x.height<=0)return;T((B)=>B.width===x.width&&B.height===x.height?B:{width:x.width,height:x.height}),l({width:x.width,height:x.height})};if(g(),typeof ResizeObserver!=="function")return;let k=new ResizeObserver(g);return k.observe(u),()=>k.disconnect()},[l]);let w=(u)=>{let g=h.current;if(!g)return null;let k=g.getBoundingClientRect(),x={x:u.clientX-k.left,y:u.clientY-k.top};return{normalized:og(k,x),px:x.x,py:x.y}},E=(u)=>{if(u.button!==0)return;let g=w(u);if(!g)return;u.preventDefault(),f(null),u.currentTarget.setPointerCapture?.(u.pointerId);let k={id:J(),tool:s,start:g.normalized,end:g.normalized,label:"",note:""};c.current=k,A(k)},I=(u)=>{let g=c.current;if(!g)return;let k=w(u);if(!k)return;let x={...g,end:k.normalized};c.current=x,A(x)},R=(u)=>{let g=c.current;if(!g)return;let k=w(u),x=k?{...g,end:k.normalized}:g;if(c.current=null,A(null),u.currentTarget.releasePointerCapture?.(u.pointerId),x.tool!=="pin"){let B=h.current?.getBoundingClientRect();if((B?Math.hypot((x.end.x-x.start.x)*B.width,(x.end.y-x.start.y)*B.height):0)<fe)return}p(x)},N=()=>{c.current=null,A(null)},L=b?[...t,b]:t;return e("div",{ref:h,className:"absolute inset-0 cursor-crosshair touch-none",onPointerDown:E,onPointerMove:I,onPointerUp:R,onPointerCancel:N,children:e("svg",{className:"absolute inset-0 w-full h-full",viewBox:`0 0 ${Math.max(1,M.width)} ${Math.max(1,M.height)}`,preserveAspectRatio:"none","aria-label":"Page annotation area",children:L.map((u,g)=>e(he,{shape:u,index:g+1,box:M,selected:u.id===r,onSelect:()=>f(u.id)},u.id))})})}function he({shape:t,index:s,box:r,selected:l,onSelect:p}){let f={x:t.start.x*r.width,y:t.start.y*r.height},h={x:t.end.x*r.width,y:t.end.y*r.height},c=Fp(t),b=l?3:2,A=String(s);return e("g",{onPointerDown:(T)=>{T.stopPropagation(),T.preventDefault(),p()},className:"cursor-pointer",children:[t.tool==="box"&&e("rect",{x:c.x*r.width,y:c.y*r.height,width:Math.max(1,c.width*r.width),height:Math.max(1,c.height*r.height),fill:_,fillOpacity:l?0.16:0.1,stroke:_,strokeWidth:b,vectorEffect:"non-scaling-stroke",rx:3}),t.tool==="arrow"&&e(d,{children:[e("line",{x1:f.x,y1:f.y,x2:h.x,y2:h.y,stroke:_,strokeWidth:b,vectorEffect:"non-scaling-stroke"}),e("circle",{cx:h.x,cy:h.y,r:4,fill:_})]}),t.tool==="pin"&&e("circle",{cx:f.x,cy:f.y,r:7,fill:_,fillOpacity:l?0.5:0.3,stroke:_,strokeWidth:b}),e("circle",{cx:f.x,cy:f.y,r:9,fill:_}),e("text",{x:f.x,y:f.y,textAnchor:"middle",dominantBaseline:"central",fontSize:11,fontWeight:700,fill:"var(--theme-paper)",children:A})]})}function te(t){let s=t.trim();if(!s)return s;let r=/^[a-z][a-z0-9+.-]*:/i.test(s)?s:`https://${s}`,l=new URL(r);if(l.protocol!=="http:"&&l.protocol!=="https:")throw Error("Only http and https URLs are allowed");return l.toString()}var ge="userBrowser.history",be="userBrowser.historyIndex",xe="userBrowser.inputUrl";function ne(){let[t,s]=S(ge,[]),[r,l]=S(be,-1),[p,f]=S(xe,""),[h,c]=n(0),[b,A]=n(!1),[M,T]=n(void 0),w=r>=0&&r<t.length?t[r]??"":"",E=a((u)=>{let g=u.trim();if(!g)return;let k;try{k=te(g)}catch(O){T(O instanceof Error?O.message:"Alamat tidak valid");return}T(void 0),A(!0);let B=[...t.slice(0,r+1),k];s(B),l(B.length-1),f(k),c((O)=>O+1)},[t,r,s,l,f]),I=a(()=>{if(r<=0)return;A(!0),l(r-1)},[r,l]),R=a(()=>{if(r>=t.length-1)return;A(!0),l(r+1)},[t.length,r,l]),N=a(()=>{if(!w)return;A(!0),c((u)=>u+1)},[w]),L=a(()=>{A(!1)},[]);return{url:w,input:p,setInput:f,frameKey:h,loading:b,error:M,canGoBack:r>0,canGoForward:r>=0&&r<t.length-1,submit:E,goBack:I,goForward:R,reload:N,markLoaded:L}}function we(t){if(!t)return"no-frame";try{return t.contentDocument?"readable":"cross-origin"}catch{return"cross-origin"}}function H(t){let s=t.replace(/\s+/g," ").trim();return s.length>60?`${s.slice(0,59)}…`:s}function ve(t){let s=t.tagName.toLowerCase();if(t.id)return`${s}#${t.id}`;for(let l of["data-testid","data-test","aria-label"]){let p=t.getAttribute(l);if(p)return`${s}[${l}="${H(p)}"]`}let r=t.getAttribute("role");if(r)return`${s}[role="${r}"]`;return s}function ye(t){let s=[],r=t;while(r&&s.length<4){if(r.tagName.toLowerCase()==="html")break;s.unshift(ve(r)),r=r.parentElement}return s.join(" > ")}function ke(t){let s=[];if(t.disabled)s.push("nonaktif");if(t instanceof HTMLSelectElement||t.tagName.toLowerCase()==="select"){let r=t,p=r.selectedOptions?.[0]?.textContent?.trim()||r.value;if(p)s.push(`nilai "${H(p)}"`);let f=r.options?.length??0;if(f>0)s.push(`${f} opsi`)}else if(t.tagName.toLowerCase()==="input"){let r=t;if(r.type)s.push(`tipe ${r.type}`);if(r.type!=="password"&&r.placeholder)s.push(`placeholder "${H(r.placeholder)}"`)}return s.length>0?s.join(", "):void 0}function Ae(t){let s={path:ye(t),tag:t.tagName.toLowerCase()},r=t.getAttribute("role");if(r)s.role=r;let l=H(t.innerText??t.textContent??"");if(l)s.text=l;let p=ke(t);if(p)s.state=p;return s}function oe(t,s){let r=we(t);if(r!=="readable")return{ok:!1,reason:r};let{contentWindow:l,contentDocument:p}=t;if(!l||!p)return{ok:!1,reason:"cross-origin"};try{let f=Math.min(Math.max(s.x,0),1)*l.innerWidth,h=Math.min(Math.max(s.y,0),1)*l.innerHeight,c=p.elementFromPoint(f,h);if(!c||c===p.documentElement||c===p.body)return{ok:!1,reason:"no-element"};return{ok:!0,element:Ae(c)}}catch{return{ok:!1,reason:"cross-origin"}}}function mt({className:t="",active:s=!0}){let[r,l]=S("userBrowser.viewportMode","responsive"),[p,f]=S("userBrowser.zoomLevel",100),[h,c]=n(null),[b,A]=n(null),[M,T]=n(null),{url:w,input:E,setInput:I,frameKey:R,loading:N,error:L,canGoBack:u,canGoForward:g,submit:k,goBack:x,goForward:B,reload:O,markLoaded:D}=ne(),v=Q(R),re=a(()=>{if(!w)return;window.open(w,"_blank","noopener,noreferrer")},[w]),ae=a(()=>{if(!w)return;Wl({url:w})},[w]),ie=a((P)=>{c((z)=>z&&z.width===P.width&&z.height===P.height?z:P)},[]),se=a((P)=>{let z=oe(b,P.start);T(z),v.add(z.ok?{...P,element:z.element}:P)},[v,b]),le=a(()=>{if(!w||v.shapes.length===0)return;let P=p/100;Wl({url:w,annotations:v.shapes,panel:{width:(h?.width??0)/P,height:(h?.height??0)/P,viewportMode:r,zoom:p}}),v.close()},[w,v,h,r,p]),G=v.active&&Boolean(w);return e("div",{className:`flex flex-col h-full w-full bg-paper text-ink overflow-hidden ${t}`,children:[e(K,{url:w,input:E,loading:N,error:L,canGoBack:u,canGoForward:g,viewportMode:r,zoomLevel:p,onInputChange:I,onSubmit:k,onBack:x,onForward:B,onReload:O,onOpenExternal:re,onIncludeInChat:ae,onChangeViewport:l,onZoomIn:()=>f((P)=>Math.min(200,P+10)),onZoomOut:()=>f((P)=>Math.max(50,P-10)),onResetZoom:()=>f(100),onSetZoom:f,annotate:{active:G,count:v.shapes.length,onToggle:v.toggle}}),G&&e(j,{tool:v.tool,shapes:v.shapes,selectedId:v.selectedId,readability:M,onTool:v.setTool,onLabel:v.setLabel,onNote:v.setNote,onRemove:v.remove,onReset:v.reset,onCancel:v.close,onSend:le}),e(X,{url:w,frameKey:R,loading:N,viewportMode:r,zoomLevel:p,onLoad:D,onFrame:A,active:s,overlay:G?e(ee,{shapes:v.shapes,tool:v.tool,selectedId:v.selectedId,onMeasure:ie,onAdd:se,onSelect:v.select}):null})]})}export{mt as UserBrowserPanel};
1
+ import{d,n,i,o,a,e,S,m,M,Vt,ma,De,C,Tn,b,og,Fp,Ru,sg,Wl}from"./index-cgzrpvzj.js";import{cu}from"./index-c3ek61zv.js";import"./index-vy6termr.js";var de={idle:"Kosong",loading:"Memuat",ready:"Siap"},V="p-1 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink cursor-pointer disabled:cursor-not-allowed transition-colors";function K({url:t,input:s,loading:r,error:l,canGoBack:p,canGoForward:f,viewportMode:h,zoomLevel:c,onInputChange:x,onSubmit:A,onBack:P,onForward:T,onReload:v,onOpenExternal:E,onIncludeInChat:O,onChangeViewport:I,onZoomIn:N,onZoomOut:L,onResetZoom:u,onSetZoom:g,annotate:k}){let w=o(void 0);i(()=>{if(w.current===t)return;if(w.current=t,t)x(t)},[t,x]);let B=!t?"idle":r?"loading":"ready",z=B==="ready"?"bg-success animate-pulse":B==="loading"?"bg-ink/40 animate-pulse":"bg-ink/25",D=e("div",{className:"flex items-center bg-canvas border border-ink/10 rounded-md p-0.5 space-x-0.5 flex-shrink-0",children:[e("button",{type:"button",onClick:P,disabled:!p,"aria-label":"Back",title:"Back",className:V,children:e(Vt,{size:12})}),e("button",{type:"button",onClick:T,disabled:!f,"aria-label":"Maju",title:"Maju",className:V,children:e(ma,{size:12})}),e("button",{type:"button",onClick:v,disabled:!t,"aria-label":"Reload",title:"Reload",className:V,children:e(C,{size:12,className:r?"animate-spin":void 0})})]});return e(cu,{url:t,statusDotClass:z,statusLabel:de[B],viewportMode:h,zoomLevel:c,onChangeViewport:I,onZoomIn:N,onZoomOut:L,onResetZoom:u,onSetZoom:g,annotate:k,onIncludeInChat:O,onOpenExternal:E,openExternalLabel:"Buka di tab baru",openExternalTitle:"Buka di tab baru (untuk situs yang menolak iframe)",children:e("div",{className:"flex items-center flex-1 min-w-0 space-x-1.5",children:[D,e("form",{className:`flex-1 min-w-0 flex items-center bg-canvas border rounded-md px-2 py-0.5 space-x-1 focus-within:border-ink/40 ${l?"border-error":"border-ink/15"}`,onSubmit:(y)=>{y.preventDefault(),A(s)},children:[e(De,{size:12,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:s,onChange:(y)=>x(y.currentTarget.value),placeholder:"Type an address (e.g. localhost:5173) and press Enter…","aria-label":"Browser address","aria-invalid":l!==void 0&&l!==null,title:l??void 0,spellcheck:!1,autoComplete:"off",className:`w-full min-w-0 bg-transparent outline-none font-mono text-[11px] placeholder:text-ink/35 ${l?"text-error":"text-ink/90"}`})]})]})})}var Z={"desktop-16-9":"w-full max-w-[1280px] aspect-video max-h-full border border-ink/20 rounded-lg shadow-md overflow-hidden my-auto",laptop:"w-[1024px] max-w-full h-[768px] max-h-full border border-ink/20 rounded-lg shadow-md overflow-hidden my-auto",tablet:"w-[768px] max-w-full h-[1024px] max-h-full border border-ink/20 rounded-lg shadow-md overflow-hidden my-auto",mobile:"w-[375px] max-w-full h-[667px] max-h-full border border-ink/20 rounded-xl shadow-md overflow-hidden my-auto","mobile-lg":"w-[414px] max-w-full h-[896px] max-h-full border border-ink/20 rounded-xl shadow-md overflow-hidden my-auto",responsive:"w-full h-full border-0"};var ce="clipboard-read; clipboard-write; fullscreen";function X({url:t,frameKey:s,loading:r,viewportMode:l,zoomLevel:p,onLoad:f,active:h=!0,overlay:c,onFrame:x}){if(!h)return null;if(!t)return e("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-center select-none",children:[e("div",{className:"w-12 h-12 rounded-xl bg-ink/5 border border-ink/10 flex items-center justify-center text-ink/40 mb-3",children:e(De,{size:22})}),e("h3",{className:"text-sm font-semibold text-ink mb-1",children:"Browser Anda"}),e("p",{className:"text-xs text-ink/60 max-w-sm",children:"Type an address above and press Enter. The page loads inside this panel."}),e("p",{className:"text-[11px] text-ink/45 max-w-sm mt-2",children:"Sebagian situs (Google, GitHub) menolak ditampilkan dalam iframe — pakai tombol buka di tab baru."})]});return e("div",{className:"flex-1 min-h-0 relative flex items-center justify-center p-2 overflow-auto bg-canvas/60",children:[r?e("div",{className:"absolute inset-0 z-10 flex items-center justify-center pointer-events-none",children:e("div",{className:"flex items-center space-x-2 px-3 py-1.5 rounded-md bg-paper border border-ink/15",children:[e(m,{size:13,className:"animate-spin text-ink/50"}),e("span",{className:"text-[11px] font-mono text-ink/60",children:"Memuat…"})]})}):null,e("div",{className:`relative flex flex-col bg-white ${Z[l]} transition-all duration-200`,style:{zoom:p!==100?`${p}%`:void 0,transformOrigin:"top center"},children:[e("iframe",{ref:(A)=>x?.(A),src:t,title:"Browser pengguna",onLoad:f,referrerPolicy:"no-referrer",allow:ce,className:"w-full h-full bg-white border-0",style:c?{pointerEvents:"none"}:void 0},s),c]})]})}var W="w-full min-w-0 bg-canvas border border-ink/15 rounded px-2 py-1 text-[11px] font-mono text-ink placeholder:text-ink/35 focus:outline-none focus:border-ink/40";function ue(t){if(!t||t.ok)return null;if(t.reason==="cross-origin")return"This page is cross-origin, so its elements cannot be read. Name the part and add a note instead.";if(t.reason==="no-frame")return"The page has not loaded, so its elements cannot be read yet.";return"There is no element at this point (empty space). Name the part instead."}function Y({shape:t,index:s,readability:r,onLabel:l,onNote:p}){let f=ue(r),h=t.element;return e("div",{className:"flex items-start gap-1.5 min-w-0",children:[e("span",{className:"text-[11px] font-mono text-ink/45 pt-1 flex-shrink-0",children:[Ru[t.tool]," #",s]}),e("div",{className:"flex-1 min-w-0 space-y-1",children:[e("div",{className:"flex items-center gap-1 flex-wrap",children:[e("span",{className:"text-[10px] uppercase font-mono text-ink/40",children:"bagian"}),sg.map((c)=>{let x=t.label===c;return e("button",{type:"button",onClick:()=>l(x?"":c),"aria-pressed":x,className:`px-1.5 py-0.5 rounded-full border text-[10px] font-mono transition-colors cursor-pointer ${x?"bg-ink text-canvas border-ink":"bg-canvas text-ink/65 border-ink/15 hover:border-ink/40"}`,children:c},c)}),e("input",{value:t.label,onInput:(c)=>l(c.currentTarget.value),placeholder:"or type your own…","aria-label":"Name of the marked part",spellcheck:!1,className:`${W} flex-1 min-w-[110px]`})]}),e("textarea",{value:t.note,onInput:(c)=>p(c.currentTarget.value),placeholder:"What is wrong with this part? (e.g. the Pay button looks disabled)",rows:2,"aria-label":"Annotation note",className:`${W} resize-y`}),h?e("p",{className:"text-[10px] font-mono text-ink/45 truncate",title:h.path,children:["elemen: ",h.path,h.state?` · ${h.state}`:""]}):null,f?e("p",{className:"text-[10px] text-ink/40",children:f}):null]})]})}var me=["box","pin","arrow"],pe="px-2 py-1 rounded text-[11px] font-mono border transition-colors cursor-pointer",F="flex items-center gap-1 px-2 py-1 rounded text-[11px] border border-ink/15 hover:border-ink/40 text-ink/80 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed";function j({tool:t,shapes:s,selectedId:r,readability:l,onTool:p,onLabel:f,onNote:h,onRemove:c,onReset:x,onCancel:A,onSend:P}){let T=s.find((E)=>E.id===r)??null,v=s.length>0;return e("div",{className:"flex-shrink-0 border-b border-ink/10 bg-paper px-2.5 py-1.5 space-y-1.5 select-none",children:[e("div",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-[10px] uppercase font-mono text-ink/50 mr-1",children:"Anotasi"}),me.map((E)=>e("button",{type:"button",onClick:()=>p(E),"aria-pressed":t===E,className:`${pe} ${t===E?"bg-ink text-canvas border-ink":"bg-canvas text-ink/70 border-ink/15 hover:border-ink/40"}`,children:Ru[E]},E)),e("span",{className:"text-[11px] font-mono text-ink/45 ml-1",children:s.length>0?`${s.length} mark${s.length===1?"":"s"}`:"drag on the page to mark a part"}),e("div",{className:"flex-1"}),e("button",{type:"button",onClick:x,disabled:!v,className:F,title:"Clear all marks",children:[e(M,{size:12})," Bersihkan"]}),e("button",{type:"button",onClick:P,disabled:!v,className:F,title:"Kirim anotasi ke draft chat",children:[e(Tn,{size:12})," Kirim ke chat"]}),e("button",{type:"button",onClick:A,className:F,title:"Tutup mode anotasi",children:e(b,{size:12})})]}),T?e("div",{className:"flex items-start gap-1.5",children:[e("div",{className:"flex-1 min-w-0",children:e(Y,{shape:T,index:s.indexOf(T)+1,readability:l,onLabel:(E)=>f(T.id,E),onNote:(E)=>h(T.id,E)})}),e("button",{type:"button",onClick:()=>c(T.id),className:F,title:"Remove this mark",children:e(M,{size:12})})]}):e("p",{className:"text-[11px] text-ink/45",children:"This page cannot be screenshotted, so what gets sent is the area, the part name and your note."})]})}var q=0;function J(){return q+=1,`annot-${Date.now().toString(36)}-${q}`}function Q(t){let[s,r]=n(!1),[l,p]=n("box"),[f,h]=n([]),[c,x]=n(null);i(()=>{h([]),x(null)},[t]);let A=a(()=>{r((N)=>!N),x(null)},[]),P=a(()=>{x(null),r(!1)},[]),T=a((N)=>{h((L)=>[...L,N]),x(N.id)},[]),v=a((N,L)=>{h((u)=>u.map((g)=>g.id===N?{...g,note:L}:g))},[]),E=a((N,L)=>{h((u)=>u.map((g)=>g.id===N?{...g,label:L}:g))},[]),O=a((N)=>{h((L)=>L.filter((u)=>u.id!==N)),x((L)=>L===N?null:L)},[]),I=a(()=>{h([]),x(null)},[]);return{active:s,tool:l,shapes:f,selectedId:c,setTool:p,toggle:A,close:P,add:T,setNote:v,setLabel:E,select:x,remove:O,reset:I}}var fe=4,U="var(--theme-error)";function ee({shapes:t,tool:s,selectedId:r,onMeasure:l,onAdd:p,onSelect:f}){let h=o(null),c=o(null),[x,A]=n(null),[P,T]=n({width:0,height:0});i(()=>{let u=h.current;if(!u)return;let g=()=>{let w=u.getBoundingClientRect();if(w.width<=0||w.height<=0)return;T((B)=>B.width===w.width&&B.height===w.height?B:{width:w.width,height:w.height}),l({width:w.width,height:w.height})};if(g(),typeof ResizeObserver!=="function")return;let k=new ResizeObserver(g);return k.observe(u),()=>k.disconnect()},[l]);let v=(u)=>{let g=h.current;if(!g)return null;let k=g.getBoundingClientRect(),w={x:u.clientX-k.left,y:u.clientY-k.top};return{normalized:og(k,w),px:w.x,py:w.y}},E=(u)=>{if(u.button!==0)return;let g=v(u);if(!g)return;u.preventDefault(),f(null),u.currentTarget.setPointerCapture?.(u.pointerId);let k={id:J(),tool:s,start:g.normalized,end:g.normalized,label:"",note:""};c.current=k,A(k)},O=(u)=>{let g=c.current;if(!g)return;let k=v(u);if(!k)return;let w={...g,end:k.normalized};c.current=w,A(w)},I=(u)=>{let g=c.current;if(!g)return;let k=v(u),w=k?{...g,end:k.normalized}:g;if(c.current=null,A(null),u.currentTarget.releasePointerCapture?.(u.pointerId),w.tool!=="pin"){let B=h.current?.getBoundingClientRect();if((B?Math.hypot((w.end.x-w.start.x)*B.width,(w.end.y-w.start.y)*B.height):0)<fe)return}p(w)},N=()=>{c.current=null,A(null)},L=x?[...t,x]:t;return e("div",{ref:h,className:"absolute inset-0 cursor-crosshair touch-none",onPointerDown:E,onPointerMove:O,onPointerUp:I,onPointerCancel:N,children:e("svg",{className:"absolute inset-0 w-full h-full",viewBox:`0 0 ${Math.max(1,P.width)} ${Math.max(1,P.height)}`,preserveAspectRatio:"none","aria-label":"Page annotation area",children:L.map((u,g)=>e(he,{shape:u,index:g+1,box:P,selected:u.id===r,onSelect:()=>f(u.id)},u.id))})})}function he({shape:t,index:s,box:r,selected:l,onSelect:p}){let f={x:t.start.x*r.width,y:t.start.y*r.height},h={x:t.end.x*r.width,y:t.end.y*r.height},c=Fp(t),x=l?3:2,A=String(s);return e("g",{onPointerDown:(T)=>{T.stopPropagation(),T.preventDefault(),p()},className:"cursor-pointer",children:[t.tool==="box"&&e("rect",{x:c.x*r.width,y:c.y*r.height,width:Math.max(1,c.width*r.width),height:Math.max(1,c.height*r.height),fill:U,fillOpacity:l?0.16:0.1,stroke:U,strokeWidth:x,vectorEffect:"non-scaling-stroke",rx:3}),t.tool==="arrow"&&e(d,{children:[e("line",{x1:f.x,y1:f.y,x2:h.x,y2:h.y,stroke:U,strokeWidth:x,vectorEffect:"non-scaling-stroke"}),e("circle",{cx:h.x,cy:h.y,r:4,fill:U})]}),t.tool==="pin"&&e("circle",{cx:f.x,cy:f.y,r:7,fill:U,fillOpacity:l?0.5:0.3,stroke:U,strokeWidth:x}),e("circle",{cx:f.x,cy:f.y,r:9,fill:U}),e("text",{x:f.x,y:f.y,textAnchor:"middle",dominantBaseline:"central",fontSize:11,fontWeight:700,fill:"var(--theme-paper)",children:A})]})}function te(t){let s=t.trim();if(!s)return s;let r=/^[a-z][a-z0-9+.-]*:/i.test(s)?s:`https://${s}`,l=new URL(r);if(l.protocol!=="http:"&&l.protocol!=="https:")throw Error("Only http and https URLs are allowed");return l.toString()}var ge="userBrowser.history",be="userBrowser.historyIndex",xe="userBrowser.inputUrl";function ne(){let[t,s]=S(ge,[]),[r,l]=S(be,-1),[p,f]=S(xe,""),[h,c]=n(0),[x,A]=n(!1),[P,T]=n(void 0),v=r>=0&&r<t.length?t[r]??"":"",E=a((u)=>{let g=u.trim();if(!g)return;let k;try{k=te(g)}catch(z){T(z instanceof Error?z.message:"Alamat tidak valid");return}T(void 0),A(!0);let B=[...t.slice(0,r+1),k];s(B),l(B.length-1),f(k),c((z)=>z+1)},[t,r,s,l,f]),O=a(()=>{if(r<=0)return;A(!0),l(r-1)},[r,l]),I=a(()=>{if(r>=t.length-1)return;A(!0),l(r+1)},[t.length,r,l]),N=a(()=>{if(!v)return;A(!0),c((u)=>u+1)},[v]),L=a(()=>{A(!1)},[]);return{url:v,input:p,setInput:f,frameKey:h,loading:x,error:P,canGoBack:r>0,canGoForward:r>=0&&r<t.length-1,submit:E,goBack:O,goForward:I,reload:N,markLoaded:L}}function we(t){if(!t)return"no-frame";try{return t.contentDocument?"readable":"cross-origin"}catch{return"cross-origin"}}function H(t){let s=t.replace(/\s+/g," ").trim();return s.length>60?`${s.slice(0,59)}…`:s}function ve(t){let s=t.tagName.toLowerCase();if(t.id)return`${s}#${t.id}`;for(let l of["data-testid","data-test","aria-label"]){let p=t.getAttribute(l);if(p)return`${s}[${l}="${H(p)}"]`}let r=t.getAttribute("role");if(r)return`${s}[role="${r}"]`;return s}function ye(t){let s=[],r=t;while(r&&s.length<4){if(r.tagName.toLowerCase()==="html")break;s.unshift(ve(r)),r=r.parentElement}return s.join(" > ")}function ke(t){let s=[];if(t.disabled)s.push("nonaktif");if(t instanceof HTMLSelectElement||t.tagName.toLowerCase()==="select"){let r=t,p=r.selectedOptions?.[0]?.textContent?.trim()||r.value;if(p)s.push(`nilai "${H(p)}"`);let f=r.options?.length??0;if(f>0)s.push(`${f} opsi`)}else if(t.tagName.toLowerCase()==="input"){let r=t;if(r.type)s.push(`tipe ${r.type}`);if(r.type!=="password"&&r.placeholder)s.push(`placeholder "${H(r.placeholder)}"`)}return s.length>0?s.join(", "):void 0}function Ae(t){let s={path:ye(t),tag:t.tagName.toLowerCase()},r=t.getAttribute("role");if(r)s.role=r;let l=H(t.innerText??t.textContent??"");if(l)s.text=l;let p=ke(t);if(p)s.state=p;return s}function oe(t,s){let r=we(t);if(r!=="readable")return{ok:!1,reason:r};let{contentWindow:l,contentDocument:p}=t;if(!l||!p)return{ok:!1,reason:"cross-origin"};try{let f=Math.min(Math.max(s.x,0),1)*l.innerWidth,h=Math.min(Math.max(s.y,0),1)*l.innerHeight,c=p.elementFromPoint(f,h);if(!c||c===p.documentElement||c===p.body)return{ok:!1,reason:"no-element"};return{ok:!0,element:Ae(c)}}catch{return{ok:!1,reason:"cross-origin"}}}function mt({className:t="",active:s=!0}){let[r,l]=S("userBrowser.viewportMode","responsive"),[p,f]=S("userBrowser.zoomLevel",100),[h,c]=n(null),[x,A]=n(null),[P,T]=n(null),{url:v,input:E,setInput:O,frameKey:I,loading:N,error:L,canGoBack:u,canGoForward:g,submit:k,goBack:w,goForward:B,reload:z,markLoaded:D}=ne(),y=Q(I),re=a(()=>{if(!v)return;window.open(v,"_blank","noopener,noreferrer")},[v]),ae=a(()=>{if(!v)return;Wl({url:v})},[v]),ie=a((R)=>{c((_)=>_&&_.width===R.width&&_.height===R.height?_:R)},[]),se=a((R)=>{let _=oe(x,R.start);T(_),y.add(_.ok?{...R,element:_.element}:R)},[y,x]),le=a(()=>{if(!v||y.shapes.length===0)return;let R=p/100;Wl({url:v,annotations:y.shapes,panel:{width:(h?.width??0)/R,height:(h?.height??0)/R,viewportMode:r,zoom:p}}),y.close()},[v,y,h,r,p]),G=y.active&&Boolean(v);return e("div",{className:`flex flex-col h-full w-full bg-paper text-ink overflow-hidden ${t}`,children:[e(K,{url:v,input:E,loading:N,error:L,canGoBack:u,canGoForward:g,viewportMode:r,zoomLevel:p,onInputChange:O,onSubmit:k,onBack:w,onForward:B,onReload:z,onOpenExternal:re,onIncludeInChat:ae,onChangeViewport:l,onZoomIn:()=>f((R)=>Math.min(200,R+10)),onZoomOut:()=>f((R)=>Math.max(50,R-10)),onResetZoom:()=>f(100),onSetZoom:f,annotate:{active:G,count:y.shapes.length,onToggle:y.toggle}}),G&&e(j,{tool:y.tool,shapes:y.shapes,selectedId:y.selectedId,readability:P,onTool:y.setTool,onLabel:y.setLabel,onNote:y.setNote,onRemove:y.remove,onReset:y.reset,onCancel:y.close,onSend:le}),e(X,{url:v,frameKey:I,loading:N,viewportMode:r,zoomLevel:p,onLoad:D,onFrame:A,active:s,overlay:G?e(ee,{shapes:y.shapes,tool:y.tool,selectedId:y.selectedId,onMeasure:ie,onAdd:se,onSelect:y.select}):null})]})}export{mt as UserBrowserPanel};
@@ -1 +1 @@
1
- import{d,n,i,o,u,a,se,e,Ap,we,S,s,f,B,ae,fa,oe,pe,C,y,le,nt,OA,no}from"./index-zt75xpq0.js";var re={name:"chevrons-up-down",size:24,node:[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]},O=s(re);function J(l,r,c=1e6){return{sessionId:l,sessionTitle:r,modelId:"",modelName:"",timestamp:"",contextUsed:0,contextLimit:c,contextPercent:0,messagesCount:0,userCount:0,assistantCount:0,totalCost:0,costFormatted:"$0.00",cacheHitAverage:0,costBreakdown:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0},lastMessage:{input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,cacheHitPercent:0},distribution:{userTokens:0,userPercent:0,assistantTokens:0,assistantPercent:0,toolTokens:0,toolPercent:0,otherTokens:0,otherPercent:100},rawMessages:[]}}function Z({used:l,limit:r,percent:c}){let x=l.toLocaleString(),m=r.toLocaleString(),t=Math.min(100,Math.max(0,c));return e("div",{className:"bg-canvas border border-ink/10 rounded-xl p-4 transition-all",children:[e("div",{className:"flex items-center justify-between text-xs mb-2",children:[e("span",{className:"font-semibold text-ink/80",children:"Context"}),e("span",{className:"font-mono text-ink/70 text-[11px]",children:[x," / ",m]})]}),e("div",{className:"w-full h-1.5 bg-ink/10 rounded-full overflow-hidden mb-2",children:e("div",{className:"h-full bg-ink/70 rounded-full transition-all duration-500 ease-out",style:{width:`${t}%`}})}),e("div",{className:"text-[11px] font-mono text-ink/50 text-left",children:[t.toFixed(1),"% used"]})]})}function _(l){return l<0.01?"$0.01":`$${l.toFixed(6).replace(/0+$/,"").replace(/\.$/,"")}`}function z({open:l,onClose:r,breakdown:c,costFormatted:x}){let m=o(null);if(le(m,r),!l)return null;let t=c?[{label:"Total Cost",value:_(c.total),strong:!0},{label:"Input (cache miss)",value:_(c.input)},{label:"Output",value:_(c.output)},{label:"Cache Read (cache hit)",value:_(c.cacheRead)},{label:"Cache Write",value:_(c.cacheWrite)}]:[{label:"Total Cost",value:x??"$0.01",strong:!0}];return e("div",{ref:m,className:"glass-popover absolute top-full right-0 mt-1.5 z-50 w-64 bg-paper border border-ink/10 rounded-lg shadow-lg p-3",role:"dialog","aria-modal":"false",children:[e("div",{className:"flex items-center justify-between mb-2.5",children:[e("span",{className:"text-xs font-semibold text-ink tracking-tight",children:"Cost Breakdown"}),e("button",{type:"button",onClick:r,className:"p-1 rounded hover:bg-ink/5 text-ink/60 hover:text-ink transition-colors","aria-label":"Close cost breakdown",children:e(y,{size:14})})]}),e("div",{className:"space-y-1.5",children:t.map((b)=>e("div",{className:"flex items-center justify-between text-[11px] font-mono border-b border-ink/5 last:border-0 pb-1.5 last:pb-0",children:[e("span",{className:"text-ink/60",children:b.label}),e("span",{className:`${b.strong?"font-semibold text-ink":"text-ink/80"}`,children:b.value})]},b.label))})]})}function V({messagesCount:l,userCount:r,assistantCount:c,costFormatted:x,cacheHitAverage:m,costBreakdown:t}){let[b,h]=n(!1);return e(d,{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Session Stats"})}),e("div",{className:"flex gap-2 flex-wrap",children:[e(nt,{variant:"compact",label:"Messages",value:l}),e(nt,{variant:"compact",label:"User",value:r}),e(nt,{variant:"compact",label:"Assistant",value:c}),e(nt,{variant:"compact",label:"Cache Hit",value:m!==void 0?`${m.toFixed(1)}%`:"–"}),e("div",{className:"relative bg-canvas border border-ink/10 rounded-lg px-2.5 py-1.5 flex flex-col gap-0.5 flex-1 min-w-0",children:[e("span",{className:"text-[10px] font-medium text-ink/50 flex items-center gap-1",children:["Cost",e("button",{type:"button",onClick:()=>h(!0),className:"p-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors","aria-label":"Show cost breakdown",title:"Cost breakdown",children:e(pe,{size:11})})]}),e("span",{className:"text-xs font-semibold font-mono text-ink truncate",children:x}),e(z,{open:b,onClose:()=>h(!1),breakdown:t,costFormatted:x})]})]})]})}function Q({input:l,output:r,reasoning:c,cacheRead:x,cacheWrite:m,cacheHitPercent:t}){return e(d,{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Last Assistant Message"})}),e("div",{className:"flex gap-2 flex-wrap",children:[e(nt,{variant:"compact",label:"In",value:l.toLocaleString()}),e(nt,{variant:"compact",label:"Out",value:r.toLocaleString()}),e(nt,{variant:"compact",label:"Reason",value:c.toLocaleString()}),e(nt,{variant:"compact",label:"Cache",value:`${x.toLocaleString()}/${m.toLocaleString()}`}),e(nt,{variant:"compact",label:"Hit",value:`${t.toFixed(1)}%`})]})]})}function G({userPercent:l,assistantPercent:r,toolPercent:c,otherPercent:x}){return e("div",{className:"space-y-2.5",children:[e("div",{className:"w-full h-1.5 rounded-full overflow-hidden flex bg-ink/10",children:[e("div",{className:"h-full bg-emerald-500 transition-all duration-300",style:{width:`${l}%`},title:`User: ${l}%`}),e("div",{className:"h-full bg-sky-500 transition-all duration-300",style:{width:`${r}%`},title:`Assistant: ${r}%`}),e("div",{className:"h-full bg-amber-500 transition-all duration-300",style:{width:`${c}%`},title:`Tool Calls: ${c}%`}),e("div",{className:"h-full bg-slate-400 transition-all duration-300",style:{width:`${x}%`},title:`Other: ${x}%`})]}),e("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-ink/70",children:[e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-emerald-500 flex-shrink-0"}),e("span",{children:["User ",l,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-sky-500 flex-shrink-0"}),e("span",{children:["Assistant ",r,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-amber-500 flex-shrink-0"}),e("span",{children:["Tool Calls ",c,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-slate-400 flex-shrink-0"}),e("span",{children:["Other ",x,"%"]})]})]})]})}function K({data:l}){no();let[r,c]=n(!1),x=o(null),m=o(null),t=JSON.stringify(l,null,2),b=OA(t),h=a((v)=>{let k=m.current;if(!k)return;k.scrollLeft=v.currentTarget.scrollLeft,k.scrollTop=v.currentTarget.scrollTop},[]),w=a(async(v)=>{v.stopPropagation();try{await navigator.clipboard.writeText(t)}catch{let k=document.createElement("textarea");k.value=t,k.style.position="fixed",k.style.opacity="0",document.body.appendChild(k),k.select(),document.execCommand("copy"),document.body.removeChild(k)}c(!0),setTimeout(()=>c(!1),2000)},[t]);return e("div",{className:"relative my-1.5 rounded-lg bg-paper/80 border border-ink/10 overflow-hidden",children:[e("div",{className:"flex items-center justify-between px-2.5 py-1.5 bg-ink/[0.04] border-b border-ink/10",children:[e("span",{className:"text-[10px] font-mono text-ink/50 select-none",children:[Object.keys(l).length," keys · ",t.length," chars"]}),e("button",{type:"button",onClick:w,className:"flex items-center space-x-1 px-2 py-1 rounded bg-canvas hover:bg-paper text-ink/70 hover:text-ink border border-ink/10 text-[10px] transition-colors shadow-xs",title:"Copy Pretty JSON",children:r?e(d,{children:[e(f,{size:11,className:"text-success"}),e("span",{className:"text-success font-sans font-medium",children:"Copied"})]}):e(d,{children:[e(oe,{size:11}),e("span",{className:"font-sans",children:"Copy JSON"})]})})]}),e("div",{className:"relative",children:[e("pre",{ref:m,"aria-hidden":!0,className:"absolute inset-0 p-2.5 m-0 font-mono text-[11px] leading-5 overflow-x-auto overflow-y-auto whitespace-pre pointer-events-none",dangerouslySetInnerHTML:{__html:b}}),e("pre",{ref:x,onScroll:h,className:"relative p-2.5 m-0 font-mono text-[11px] leading-5 overflow-x-auto overflow-y-auto whitespace-pre select-text selection:bg-ink selection:text-canvas",children:e("code",{className:"text-transparent",children:t})})]})]})}var j=["bg-emerald-500","bg-sky-500","bg-amber-500","bg-violet-500","bg-rose-500","bg-teal-500","bg-indigo-500","bg-fuchsia-500","bg-lime-500","bg-cyan-500","bg-orange-500","bg-pink-500","bg-yellow-500","bg-purple-500","bg-red-500","bg-blue-500","bg-green-500","bg-cyan-600","bg-violet-600","bg-amber-600"],I=20;function q(l){let r=0;for(let c=0;c<l.length;c++)r=r*31+l.charCodeAt(c)|0;return Math.abs(r)}function Y(l){let r=l.indexOf("/"),c=r>0?l.slice(0,r):l,x=r>0?l.slice(r+1):"";return x?`${c} · ${x}`:c}function X(l,r){if(r<=7)return Array.from({length:r},(b,h)=>h+1);let c=new Set([1,r,l,l-1,l+1]);if(l<=3)[2,3,4].forEach((b)=>c.add(b));if(l>=r-2)[r-3,r-2,r-1].forEach((b)=>c.add(b));let x=[...c].filter((b)=>b>=1&&b<=r).sort((b,h)=>b-h),m=[],t=0;for(let b of x){if(b-t>1)m.push("…");m.push(b),t=b}return m}function ee({sessionId:l,refreshKey:r=0}){let[c,x]=S("context.rawExpandedIds",{}),[m,t]=S("context.rawFilterRole","all"),[b,h]=n(1),[w,v]=n([]),[k,W]=n(0),[T,N]=n(!1),E=o(0),U=o(!1),A=a((p)=>{if(typeof window>"u")return;let g=++E.current;if(!p?.silent)N(!0);let R=new URLSearchParams({page:String(b),pageSize:String(I),role:m});if(l)R.set("sessionId",l);fetch(`/api/telemetry/raw-messages?${R.toString()}`).then((M)=>M.ok?M.json():null).then((M)=>{if(U.current||g!==E.current)return;v(M&&Array.isArray(M.items)?M.items:[]),W(M&&Number.isFinite(M.filteredTotal)?M.filteredTotal:0)}).catch(()=>{if(U.current||g!==E.current)return;v([]),W(0)}).finally(()=>{if(!p?.silent&&g===E.current)N(!1)})},[l,b,m]);i(()=>(U.current=!1,A(),()=>{U.current=!0}),[A,r]);let L=Math.max(1,Math.ceil(k/I)),P=Math.min(b,L),D=(p)=>h(Math.min(Math.max(1,p),L)),te=(p)=>{x((g)=>({...g,[p]:!g[p]}))},ne=()=>{if(w.every((g)=>c[g.id]))x({});else{let g={};w.forEach((R)=>{g[R.id]=!0}),x(g)}},F=u(()=>{let p=[];for(let g of w){let R=g.info.modelID;if(!R||p.includes(R))continue;p.push(R)}return p},[w]),H=(p)=>p?j[q(p)%j.length]:"bg-ink/20";return e("div",{className:"space-y-3",children:[F.length>0&&e("div",{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Legend"})}),e("div",{className:"bg-canvas border border-ink/10 rounded-xl px-3 py-2",children:e("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] font-mono text-ink/60",children:F.map((p)=>e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:`w-2 h-2 rounded-full ${H(p)}`}),e("span",{children:Y(p)})]},p))})})]}),e("div",{className:"flex items-center justify-between",children:[e("div",{className:"flex items-center space-x-2",children:[e("span",{className:"text-xs font-semibold text-ink/80",children:"Raw Messages"}),e("span",{className:"text-[10px] font-mono text-ink/50 bg-ink/5 px-1.5 py-0.5 rounded-full border border-ink/10",children:k})]}),e("div",{className:"flex items-center space-x-1",children:[e("div",{className:"flex items-center bg-canvas border border-ink/10 rounded-lg p-0.5 text-[10px]",children:[e("button",{type:"button",onClick:()=>{t("all"),h(1)},className:`px-1.5 py-0.5 rounded ${m==="all"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"All"}),e("button",{type:"button",onClick:()=>{t("assistant"),h(1)},className:`px-1.5 py-0.5 rounded ${m==="assistant"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"AI"}),e("button",{type:"button",onClick:()=>{t("user"),h(1)},className:`px-1.5 py-0.5 rounded ${m==="user"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"User"})]}),e("button",{type:"button",onClick:ne,className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors text-[10px] flex items-center",title:"Expand / Collapse All",children:e(O,{size:14})})]})]}),e("div",{className:"space-y-1.5",children:!T&&w.length===0?e("div",{className:"p-4 text-center text-xs text-ink/40 italic bg-canvas rounded-xl border border-ink/10",children:"No raw messages recorded yet."}):w.map((p)=>{let g=Boolean(c[p.id]);return e("div",{className:`bg-canvas border border-ink/10 rounded-xl overflow-hidden transition-all duration-200 ${T?"opacity-50":""}`,children:[e("button",{type:"button",onClick:()=>te(p.id),className:"w-full text-left px-3.5 py-2.5 flex items-center justify-between hover:bg-ink/5 transition-colors cursor-pointer",children:[e("div",{className:"flex items-center space-x-2 min-w-0 flex-1 mr-2",children:[e("span",{className:"text-ink/40 flex-shrink-0",children:g?e(B,{size:14}):e(ae,{size:14})}),e("span",{className:"text-xs font-mono text-ink/90 truncate",children:p.badgeLabel})]}),e("div",{className:"flex items-center space-x-3 text-[11px] font-mono text-ink/50 flex-shrink-0",children:[p.tokenSummary&&e("span",{className:"text-ink/60",children:p.tokenSummary}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:`w-2 h-2 rounded-full ${H(p.info.modelID)}`}),e("span",{children:p.timestamp})]})]})]}),g&&e("div",{className:"px-3.5 pb-3 pt-1 border-t border-ink/5 bg-canvas/60",children:e(K,{data:p.rawPayload})})]},p.id)})}),L>1&&e("div",{className:"flex items-center justify-between pt-1",children:[e("span",{className:"text-[10px] font-mono text-ink/50",children:[(P-1)*I+1,"–",Math.min(P*I,k)," of ",k]}),e("div",{className:"flex items-center gap-0.5",children:[e("button",{type:"button",disabled:P<=1,onClick:()=>D(P-1),className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-30 disabled:hover:bg-transparent transition-colors",title:"Previous page",children:e(fa,{size:14})}),X(P,L).map((p,g)=>p==="…"?e("span",{className:"px-1 text-[10px] font-mono text-ink/40 select-none",children:"…"},`gap-${g}`):e("button",{type:"button",onClick:()=>D(p),className:`min-w-[22px] h-[22px] px-1 rounded text-[10px] font-mono transition-colors ${p===P?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink hover:bg-ink/5"}`,children:p},p)),e("button",{type:"button",disabled:P>=L,onClick:()=>D(P+1),className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-30 disabled:hover:bg-transparent transition-colors",title:"Next page",children:e(ae,{size:14})})]})]})]})}function dt({className:l="",enabled:r=!0,refreshKey:c=0}){let[x]=se(),m=x.get("sessionId"),[t,b]=n(()=>J(m||"default","Session not started")),h=o(!1),w=a(()=>{if(typeof window>"u")return;let T=m?`?sessionId=${encodeURIComponent(m)}`:"";fetch(`/api/telemetry/context${T}`).then((N)=>N.ok?N.json():null).then((N)=>{if(!h.current&&N&&N.telemetry)b(N.telemetry)}).catch((N)=>{if(!h.current)console.warn("Failed to fetch context telemetry:",N)})},[m]);i(()=>{if(h.current=!1,!r)return;return w(),()=>{h.current=!0}},[r,c,w]);let v=we(m?Ap(m):null,{enabled:r}),[k,W]=n(0);if(i(()=>{if(v.data)b(v.data),W((T)=>T+1)},[v.data]),!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${l}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});if(t.messagesCount===0)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${l}`,children:e("span",{className:"text-xs font-mono",children:"Session not started"})});return e("div",{className:`flex flex-col h-full bg-paper text-ink overflow-hidden select-none ${l}`,children:[e("div",{className:"flex-shrink-0 p-4 border-b border-ink/10 bg-paper",children:e("div",{className:"flex items-start justify-between gap-2",children:[e("div",{className:"min-w-0",children:[e("h2",{className:"text-xs font-medium text-ink tracking-tight truncate",children:t.sessionTitle}),e("div",{className:"text-[11px] text-ink/50 mt-1 truncate font-mono",children:t.timestamp})]}),e("button",{type:"button",onClick:()=>{v.refresh(),w()},disabled:!r,title:"Refresh context telemetry","aria-label":"Refresh context telemetry","aria-busy":v.refreshing,className:"flex-shrink-0 rounded-md border border-ink/15 bg-paper p-1.5 text-ink/80 transition-colors hover:bg-ink/5 disabled:opacity-50",children:e(C,{size:12,className:v.refreshing?"animate-spin text-ink":""})})]})}),e("div",{className:"flex-1 scrollbar-overlay-container p-4 space-y-4",children:[e(Z,{used:t.contextUsed,limit:t.contextLimit,percent:t.contextPercent}),e(V,{messagesCount:t.messagesCount,userCount:t.userCount,assistantCount:t.assistantCount,costFormatted:t.costFormatted,cacheHitAverage:t.cacheHitAverage,costBreakdown:t.costBreakdown}),e(Q,{input:t.lastMessage.input,output:t.lastMessage.output,reasoning:t.lastMessage.reasoning,cacheRead:t.lastMessage.cacheRead,cacheWrite:t.lastMessage.cacheWrite,cacheHitPercent:t.lastMessage.cacheHitPercent}),e(G,{userPercent:t.distribution.userPercent,assistantPercent:t.distribution.assistantPercent,toolPercent:t.distribution.toolPercent,otherPercent:t.distribution.otherPercent}),e(ee,{sessionId:m,refreshKey:c+k})]})]})}export{dt as ContextPanel};
1
+ import{d,n,i,o,u,a,le,e,Ap,we,S,s,f,B,ie,Aa,ae,pe,C,b,ce,nt,OA,no}from"./index-cgzrpvzj.js";var ne={name:"chevrons-up-down",size:24,node:[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]},O=s(ne);function J(l,r,c=1e6){return{sessionId:l,sessionTitle:r,modelId:"",modelName:"",timestamp:"",contextUsed:0,contextLimit:c,contextPercent:0,messagesCount:0,userCount:0,assistantCount:0,totalCost:0,costFormatted:"$0.00",cacheHitAverage:0,costBreakdown:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0},lastMessage:{input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,cacheHitPercent:0},distribution:{userTokens:0,userPercent:0,assistantTokens:0,assistantPercent:0,toolTokens:0,toolPercent:0,otherTokens:0,otherPercent:100},rawMessages:[]}}function Z({used:l,limit:r,percent:c}){let h=l.toLocaleString(),m=r.toLocaleString(),t=Math.min(100,Math.max(0,c));return e("div",{className:"bg-canvas border border-ink/10 rounded-xl p-4 transition-all",children:[e("div",{className:"flex items-center justify-between text-xs mb-2",children:[e("span",{className:"font-semibold text-ink/80",children:"Context"}),e("span",{className:"font-mono text-ink/70 text-[11px]",children:[h," / ",m]})]}),e("div",{className:"w-full h-1.5 bg-ink/10 rounded-full overflow-hidden mb-2",children:e("div",{className:"h-full bg-ink/70 rounded-full transition-all duration-500 ease-out",style:{width:`${t}%`}})}),e("div",{className:"text-[11px] font-mono text-ink/50 text-left",children:[t.toFixed(1),"% used"]})]})}function _(l){return l<0.01?"$0.01":`$${l.toFixed(6).replace(/0+$/,"").replace(/\.$/,"")}`}function z({open:l,onClose:r,breakdown:c,costFormatted:h}){let m=o(null);if(ce(m,r),!l)return null;let t=c?[{label:"Total Cost",value:_(c.total),strong:!0},{label:"Input (cache miss)",value:_(c.input)},{label:"Output",value:_(c.output)},{label:"Cache Read (cache hit)",value:_(c.cacheRead)},{label:"Cache Write",value:_(c.cacheWrite)}]:[{label:"Total Cost",value:h??"$0.01",strong:!0}];return e("div",{ref:m,className:"glass-popover absolute top-full right-0 mt-1.5 z-50 w-64 bg-paper border border-ink/10 rounded-lg shadow-lg p-3",role:"dialog","aria-modal":"false",children:[e("div",{className:"flex items-center justify-between mb-2.5",children:[e("span",{className:"text-xs font-semibold text-ink tracking-tight",children:"Cost Breakdown"}),e("button",{type:"button",onClick:r,className:"p-1 rounded hover:bg-ink/5 text-ink/60 hover:text-ink transition-colors","aria-label":"Close cost breakdown",children:e(b,{size:14})})]}),e("div",{className:"space-y-1.5",children:t.map((x)=>e("div",{className:"flex items-center justify-between text-[11px] font-mono border-b border-ink/5 last:border-0 pb-1.5 last:pb-0",children:[e("span",{className:"text-ink/60",children:x.label}),e("span",{className:`${x.strong?"font-semibold text-ink":"text-ink/80"}`,children:x.value})]},x.label))})]})}function V({messagesCount:l,userCount:r,assistantCount:c,costFormatted:h,cacheHitAverage:m,costBreakdown:t}){let[x,g]=n(!1);return e(d,{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Session Stats"})}),e("div",{className:"flex gap-2 flex-wrap",children:[e(nt,{variant:"compact",label:"Messages",value:l}),e(nt,{variant:"compact",label:"User",value:r}),e(nt,{variant:"compact",label:"Assistant",value:c}),e(nt,{variant:"compact",label:"Cache Hit",value:m!==void 0?`${m.toFixed(1)}%`:"–"}),e("div",{className:"relative bg-canvas border border-ink/10 rounded-lg px-2.5 py-1.5 flex flex-col gap-0.5 flex-1 min-w-0",children:[e("span",{className:"text-[10px] font-medium text-ink/50 flex items-center gap-1",children:["Cost",e("button",{type:"button",onClick:()=>g(!0),className:"p-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors","aria-label":"Show cost breakdown",title:"Cost breakdown",children:e(pe,{size:11})})]}),e("span",{className:"text-xs font-semibold font-mono text-ink truncate",children:h}),e(z,{open:x,onClose:()=>g(!1),breakdown:t,costFormatted:h})]})]})]})}function Q({input:l,output:r,reasoning:c,cacheRead:h,cacheWrite:m,cacheHitPercent:t}){return e(d,{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Last Assistant Message"})}),e("div",{className:"flex gap-2 flex-wrap",children:[e(nt,{variant:"compact",label:"In",value:l.toLocaleString()}),e(nt,{variant:"compact",label:"Out",value:r.toLocaleString()}),e(nt,{variant:"compact",label:"Reason",value:c.toLocaleString()}),e(nt,{variant:"compact",label:"Cache",value:`${h.toLocaleString()}/${m.toLocaleString()}`}),e(nt,{variant:"compact",label:"Hit",value:`${t.toFixed(1)}%`})]})]})}function G({userPercent:l,assistantPercent:r,toolPercent:c,otherPercent:h}){return e("div",{className:"space-y-2.5",children:[e("div",{className:"w-full h-1.5 rounded-full overflow-hidden flex bg-ink/10",children:[e("div",{className:"h-full bg-emerald-500 transition-all duration-300",style:{width:`${l}%`},title:`User: ${l}%`}),e("div",{className:"h-full bg-sky-500 transition-all duration-300",style:{width:`${r}%`},title:`Assistant: ${r}%`}),e("div",{className:"h-full bg-amber-500 transition-all duration-300",style:{width:`${c}%`},title:`Tool Calls: ${c}%`}),e("div",{className:"h-full bg-slate-400 transition-all duration-300",style:{width:`${h}%`},title:`Other: ${h}%`})]}),e("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-ink/70",children:[e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-emerald-500 flex-shrink-0"}),e("span",{children:["User ",l,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-sky-500 flex-shrink-0"}),e("span",{children:["Assistant ",r,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-amber-500 flex-shrink-0"}),e("span",{children:["Tool Calls ",c,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-slate-400 flex-shrink-0"}),e("span",{children:["Other ",h,"%"]})]})]})]})}function K({data:l}){no();let[r,c]=n(!1),h=o(null),m=o(null),t=JSON.stringify(l,null,2),x=OA(t),g=a((y)=>{let v=m.current;if(!v)return;v.scrollLeft=y.currentTarget.scrollLeft,v.scrollTop=y.currentTarget.scrollTop},[]),w=a(async(y)=>{y.stopPropagation();try{await navigator.clipboard.writeText(t)}catch{let v=document.createElement("textarea");v.value=t,v.style.position="fixed",v.style.opacity="0",document.body.appendChild(v),v.select(),document.execCommand("copy"),document.body.removeChild(v)}c(!0),setTimeout(()=>c(!1),2000)},[t]);return e("div",{className:"relative my-1.5 rounded-lg bg-paper/80 border border-ink/10 overflow-hidden",children:[e("div",{className:"flex items-center justify-between px-2.5 py-1.5 bg-ink/[0.04] border-b border-ink/10",children:[e("span",{className:"text-[10px] font-mono text-ink/50 select-none",children:[Object.keys(l).length," keys · ",t.length," chars"]}),e("button",{type:"button",onClick:w,className:"flex items-center space-x-1 px-2 py-1 rounded bg-canvas hover:bg-paper text-ink/70 hover:text-ink border border-ink/10 text-[10px] transition-colors shadow-xs",title:"Copy Pretty JSON",children:r?e(d,{children:[e(f,{size:11,className:"text-success"}),e("span",{className:"text-success font-sans font-medium",children:"Copied"})]}):e(d,{children:[e(ae,{size:11}),e("span",{className:"font-sans",children:"Copy JSON"})]})})]}),e("div",{className:"relative",children:[e("pre",{ref:m,"aria-hidden":!0,className:"absolute inset-0 p-2.5 m-0 font-mono text-[11px] leading-5 overflow-x-auto overflow-y-auto whitespace-pre pointer-events-none",dangerouslySetInnerHTML:{__html:x}}),e("pre",{ref:h,onScroll:g,className:"relative p-2.5 m-0 font-mono text-[11px] leading-5 overflow-x-auto overflow-y-auto whitespace-pre select-text selection:bg-ink selection:text-canvas",children:e("code",{className:"text-transparent",children:t})})]})]})}var j=["bg-emerald-500","bg-sky-500","bg-amber-500","bg-violet-500","bg-rose-500","bg-teal-500","bg-indigo-500","bg-fuchsia-500","bg-lime-500","bg-cyan-500","bg-orange-500","bg-pink-500","bg-yellow-500","bg-purple-500","bg-red-500","bg-blue-500","bg-green-500","bg-cyan-600","bg-violet-600","bg-amber-600"],I=20;function q(l){let r=0;for(let c=0;c<l.length;c++)r=r*31+l.charCodeAt(c)|0;return Math.abs(r)}function Y(l){let r=l.indexOf("/"),c=r>0?l.slice(0,r):l,h=r>0?l.slice(r+1):"";return h?`${c} · ${h}`:c}function X(l,r){if(r<=7)return Array.from({length:r},(x,g)=>g+1);let c=new Set([1,r,l,l-1,l+1]);if(l<=3)[2,3,4].forEach((x)=>c.add(x));if(l>=r-2)[r-3,r-2,r-1].forEach((x)=>c.add(x));let h=[...c].filter((x)=>x>=1&&x<=r).sort((x,g)=>x-g),m=[],t=0;for(let x of h){if(x-t>1)m.push("…");m.push(x),t=x}return m}function ee({sessionId:l,refreshKey:r=0}){let[c,h]=S("context.rawExpandedIds",{}),[m,t]=S("context.rawFilterRole","all"),[x,g]=n(1),[w,y]=n([]),[v,W]=n(0),[T,N]=n(!1),E=o(0),U=o(!1),A=a((p)=>{if(typeof window>"u")return;let k=++E.current;if(!p?.silent)N(!0);let R=new URLSearchParams({page:String(x),pageSize:String(I),role:m});if(l)R.set("sessionId",l);fetch(`/api/telemetry/raw-messages?${R.toString()}`).then((M)=>M.ok?M.json():null).then((M)=>{if(U.current||k!==E.current)return;y(M&&Array.isArray(M.items)?M.items:[]),W(M&&Number.isFinite(M.filteredTotal)?M.filteredTotal:0)}).catch(()=>{if(U.current||k!==E.current)return;y([]),W(0)}).finally(()=>{if(!p?.silent&&k===E.current)N(!1)})},[l,x,m]);i(()=>(U.current=!1,A(),()=>{U.current=!0}),[A,r]);let L=Math.max(1,Math.ceil(v/I)),P=Math.min(x,L),D=(p)=>g(Math.min(Math.max(1,p),L)),te=(p)=>{h((k)=>({...k,[p]:!k[p]}))},se=()=>{if(w.every((k)=>c[k.id]))h({});else{let k={};w.forEach((R)=>{k[R.id]=!0}),h(k)}},F=u(()=>{let p=[];for(let k of w){let R=k.info.modelID;if(!R||p.includes(R))continue;p.push(R)}return p},[w]),H=(p)=>p?j[q(p)%j.length]:"bg-ink/20";return e("div",{className:"space-y-3",children:[F.length>0&&e("div",{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Legend"})}),e("div",{className:"bg-canvas border border-ink/10 rounded-xl px-3 py-2",children:e("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] font-mono text-ink/60",children:F.map((p)=>e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:`w-2 h-2 rounded-full ${H(p)}`}),e("span",{children:Y(p)})]},p))})})]}),e("div",{className:"flex items-center justify-between",children:[e("div",{className:"flex items-center space-x-2",children:[e("span",{className:"text-xs font-semibold text-ink/80",children:"Raw Messages"}),e("span",{className:"text-[10px] font-mono text-ink/50 bg-ink/5 px-1.5 py-0.5 rounded-full border border-ink/10",children:v})]}),e("div",{className:"flex items-center space-x-1",children:[e("div",{className:"flex items-center bg-canvas border border-ink/10 rounded-lg p-0.5 text-[10px]",children:[e("button",{type:"button",onClick:()=>{t("all"),g(1)},className:`px-1.5 py-0.5 rounded ${m==="all"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"All"}),e("button",{type:"button",onClick:()=>{t("assistant"),g(1)},className:`px-1.5 py-0.5 rounded ${m==="assistant"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"AI"}),e("button",{type:"button",onClick:()=>{t("user"),g(1)},className:`px-1.5 py-0.5 rounded ${m==="user"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"User"})]}),e("button",{type:"button",onClick:se,className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors text-[10px] flex items-center",title:"Expand / Collapse All",children:e(O,{size:14})})]})]}),e("div",{className:"space-y-1.5",children:!T&&w.length===0?e("div",{className:"p-4 text-center text-xs text-ink/40 italic bg-canvas rounded-xl border border-ink/10",children:"No raw messages recorded yet."}):w.map((p)=>{let k=Boolean(c[p.id]);return e("div",{className:`bg-canvas border border-ink/10 rounded-xl overflow-hidden transition-all duration-200 ${T?"opacity-50":""}`,children:[e("button",{type:"button",onClick:()=>te(p.id),className:"w-full text-left px-3.5 py-2.5 flex items-center justify-between hover:bg-ink/5 transition-colors cursor-pointer",children:[e("div",{className:"flex items-center space-x-2 min-w-0 flex-1 mr-2",children:[e("span",{className:"text-ink/40 flex-shrink-0",children:k?e(B,{size:14}):e(ie,{size:14})}),e("span",{className:"text-xs font-mono text-ink/90 truncate",children:p.badgeLabel})]}),e("div",{className:"flex items-center space-x-3 text-[11px] font-mono text-ink/50 flex-shrink-0",children:[p.tokenSummary&&e("span",{className:"text-ink/60",children:p.tokenSummary}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:`w-2 h-2 rounded-full ${H(p.info.modelID)}`}),e("span",{children:p.timestamp})]})]})]}),k&&e("div",{className:"px-3.5 pb-3 pt-1 border-t border-ink/5 bg-canvas/60",children:e(K,{data:p.rawPayload})})]},p.id)})}),L>1&&e("div",{className:"flex items-center justify-between pt-1",children:[e("span",{className:"text-[10px] font-mono text-ink/50",children:[(P-1)*I+1,"–",Math.min(P*I,v)," of ",v]}),e("div",{className:"flex items-center gap-0.5",children:[e("button",{type:"button",disabled:P<=1,onClick:()=>D(P-1),className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-30 disabled:hover:bg-transparent transition-colors",title:"Previous page",children:e(Aa,{size:14})}),X(P,L).map((p,k)=>p==="…"?e("span",{className:"px-1 text-[10px] font-mono text-ink/40 select-none",children:"…"},`gap-${k}`):e("button",{type:"button",onClick:()=>D(p),className:`min-w-[22px] h-[22px] px-1 rounded text-[10px] font-mono transition-colors ${p===P?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink hover:bg-ink/5"}`,children:p},p)),e("button",{type:"button",disabled:P>=L,onClick:()=>D(P+1),className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-30 disabled:hover:bg-transparent transition-colors",title:"Next page",children:e(ie,{size:14})})]})]})]})}function dt({className:l="",enabled:r=!0,refreshKey:c=0}){let[h]=le(),m=h.get("sessionId"),[t,x]=n(()=>J(m||"default","Session not started")),g=o(!1),w=a(()=>{if(typeof window>"u")return;let T=m?`?sessionId=${encodeURIComponent(m)}`:"";fetch(`/api/telemetry/context${T}`).then((N)=>N.ok?N.json():null).then((N)=>{if(!g.current&&N&&N.telemetry)x(N.telemetry)}).catch((N)=>{if(!g.current)console.warn("Failed to fetch context telemetry:",N)})},[m]);i(()=>{if(g.current=!1,!r)return;return w(),()=>{g.current=!0}},[r,c,w]);let y=we(m?Ap(m):null,{enabled:r}),[v,W]=n(0);if(i(()=>{if(y.data)x(y.data),W((T)=>T+1)},[y.data]),!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${l}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});if(t.messagesCount===0)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${l}`,children:e("span",{className:"text-xs font-mono",children:"Session not started"})});return e("div",{className:`flex flex-col h-full bg-paper text-ink overflow-hidden select-none ${l}`,children:[e("div",{className:"flex-shrink-0 p-4 border-b border-ink/10 bg-paper",children:e("div",{className:"flex items-start justify-between gap-2",children:[e("div",{className:"min-w-0",children:[e("h2",{className:"text-xs font-medium text-ink tracking-tight truncate",children:t.sessionTitle}),e("div",{className:"text-[11px] text-ink/50 mt-1 truncate font-mono",children:t.timestamp})]}),e("button",{type:"button",onClick:()=>{y.refresh(),w()},disabled:!r,title:"Refresh context telemetry","aria-label":"Refresh context telemetry","aria-busy":y.refreshing,className:"flex-shrink-0 rounded-md border border-ink/15 bg-paper p-1.5 text-ink/80 transition-colors hover:bg-ink/5 disabled:opacity-50",children:e(C,{size:12,className:y.refreshing?"animate-spin text-ink":""})})]})}),e("div",{className:"flex-1 scrollbar-overlay-container p-4 space-y-4",children:[e(Z,{used:t.contextUsed,limit:t.contextLimit,percent:t.contextPercent}),e(V,{messagesCount:t.messagesCount,userCount:t.userCount,assistantCount:t.assistantCount,costFormatted:t.costFormatted,cacheHitAverage:t.cacheHitAverage,costBreakdown:t.costBreakdown}),e(Q,{input:t.lastMessage.input,output:t.lastMessage.output,reasoning:t.lastMessage.reasoning,cacheRead:t.lastMessage.cacheRead,cacheWrite:t.lastMessage.cacheWrite,cacheHitPercent:t.lastMessage.cacheHitPercent}),e(G,{userPercent:t.distribution.userPercent,assistantPercent:t.distribution.assistantPercent,toolPercent:t.distribution.toolPercent,otherPercent:t.distribution.otherPercent}),e(ee,{sessionId:m,refreshKey:c+v})]})]})}export{dt as ContextPanel};
@@ -1,2 +1,2 @@
1
- import{n,i,s,H,Wr,Jl,Pf,Of,yg,Wp}from"./index-zt75xpq0.js";var p={name:"save",size:24,node:[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]},yt=s(p);var ad="omp:editor-theme-changed";function a(){if(typeof window>"u")return Jl;return H("editorTheme")??Jl}var m={theme:null,vars:{},themes:Of(null)};function uo(){let[e,t]=n(a);if(i(()=>{let r=(d)=>{let E=d.detail;t(E||a())};return window.addEventListener(ad,r),()=>window.removeEventListener(ad,r)},[]),i(()=>{Wp(e)},[e]),e===Wr)return m;let o=Pf(e);return{theme:o,vars:yg(o),themes:Of(e)}}var id="omp:editor-indent-changed",od=[2,4,8],Uc={width:2,insertSpaces:!0};function sd(){if(typeof window>"u")return Uc;let e=H("editorIndentWidth"),t=H("editorInsertSpaces");return{width:typeof e==="number"&&od.includes(e)?e:Uc.width,insertSpaces:typeof t==="boolean"?t:Uc.insertSpaces}}function Gc(e){return e.insertSpaces?" ".repeat(e.width):"\t"}function jc(){let[e,t]=n(sd);return i(()=>{let o=(r)=>{let d=r.detail;t(d??sd())};return window.addEventListener(id,o),()=>window.removeEventListener(id,o)},[]),e}var ld="omp:editor-typing-changed",il={autoCloseBrackets:!0,autocomplete:!0};function qc(){if(typeof window>"u")return il;let e=H("editorAutoCloseBrackets"),t=H("editorAutocomplete");return{autoCloseBrackets:typeof e==="boolean"?e:il.autoCloseBrackets,autocomplete:typeof t==="boolean"?t:il.autocomplete}}function Hc(){let[e,t]=n(qc);return i(()=>{let o=(r)=>{let d=r.detail;t(d??qc())};return window.addEventListener(ld,o),()=>window.removeEventListener(ld,o)},[]),e}var is="omp:editor-blame-changed",ol={enabled:!0,inline:!1};function po(){if(typeof window>"u")return ol;let e=H("editorBlame"),t=H("editorBlameInline");return{enabled:typeof e==="boolean"?e:ol.enabled,inline:typeof t==="boolean"?t:ol.inline}}function cd(){let[e,t]=n(po);return i(()=>{let o=(r)=>{let d=r.detail;t(d??po())};return window.addEventListener(is,o),()=>window.removeEventListener(is,o)},[]),e}
1
+ import{n,i,s,H,Kr,Jl,Pf,Of,yg,Wp}from"./index-cgzrpvzj.js";var p={name:"save",size:24,node:[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]},yt=s(p);var ad="omp:editor-theme-changed";function a(){if(typeof window>"u")return Jl;return H("editorTheme")??Jl}var m={theme:null,vars:{},themes:Of(null)};function uo(){let[e,t]=n(a);if(i(()=>{let r=(d)=>{let E=d.detail;t(E||a())};return window.addEventListener(ad,r),()=>window.removeEventListener(ad,r)},[]),i(()=>{Wp(e)},[e]),e===Kr)return m;let o=Pf(e);return{theme:o,vars:yg(o),themes:Of(e)}}var id="omp:editor-indent-changed",od=[2,4,8],Uc={width:2,insertSpaces:!0};function sd(){if(typeof window>"u")return Uc;let e=H("editorIndentWidth"),t=H("editorInsertSpaces");return{width:typeof e==="number"&&od.includes(e)?e:Uc.width,insertSpaces:typeof t==="boolean"?t:Uc.insertSpaces}}function Gc(e){return e.insertSpaces?" ".repeat(e.width):"\t"}function jc(){let[e,t]=n(sd);return i(()=>{let o=(r)=>{let d=r.detail;t(d??sd())};return window.addEventListener(id,o),()=>window.removeEventListener(id,o)},[]),e}var ld="omp:editor-typing-changed",il={autoCloseBrackets:!0,autocomplete:!0};function qc(){if(typeof window>"u")return il;let e=H("editorAutoCloseBrackets"),t=H("editorAutocomplete");return{autoCloseBrackets:typeof e==="boolean"?e:il.autoCloseBrackets,autocomplete:typeof t==="boolean"?t:il.autocomplete}}function Hc(){let[e,t]=n(qc);return i(()=>{let o=(r)=>{let d=r.detail;t(d??qc())};return window.addEventListener(ld,o),()=>window.removeEventListener(ld,o)},[]),e}var is="omp:editor-blame-changed",ol={enabled:!0,inline:!1};function po(){if(typeof window>"u")return ol;let e=H("editorBlame"),t=H("editorBlameInline");return{enabled:typeof e==="boolean"?e:ol.enabled,inline:typeof t==="boolean"?t:ol.inline}}function cd(){let[e,t]=n(po);return i(()=>{let o=(r)=>{let d=r.detail;t(d??po())};return window.addEventListener(is,o),()=>window.removeEventListener(is,o)},[]),e}
2
2
  export{yt,ad,uo,id,od,Uc,sd,Gc,jc,ld,il,qc,Hc,is,ol,po,cd};