@diffohq/diffo 0.16.0 → 0.17.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 (96) hide show
  1. package/dist/client/assets/{abnfDiagram-O67JEVCF-BeUwVmdl.js → abnfDiagram-O67JEVCF-C4y4PNNf.js} +1 -1
  2. package/dist/client/assets/{arc-DOjPzaV7.js → arc-CFoc9vPw.js} +1 -1
  3. package/dist/client/assets/architecture-7GRP2DOG-D0AGQ72s.js +1 -0
  4. package/dist/client/assets/{architectureDiagram-NJMV4G6O-BenBz3HF.js → architectureDiagram-NJMV4G6O-Dr2fN1vr.js} +1 -1
  5. package/dist/client/assets/{blockDiagram-BEXU5L5S-C3ubUdn6.js → blockDiagram-BEXU5L5S-CpA03aJs.js} +1 -1
  6. package/dist/client/assets/{c4Diagram-YGBWAQC7-Cd_s02_p.js → c4Diagram-YGBWAQC7-CYMsQutS.js} +1 -1
  7. package/dist/client/assets/channel-BktdIn5n.js +1 -0
  8. package/dist/client/assets/{chunk-3FUC2YCW-DNC8xTT6.js → chunk-3FUC2YCW-BjQ1itX5.js} +1 -1
  9. package/dist/client/assets/{chunk-5DYCD2WN-wrFKk0N8.js → chunk-5DYCD2WN-BmQXtfyC.js} +1 -1
  10. package/dist/client/assets/{chunk-742MDFTN-C6HG0C5O.js → chunk-742MDFTN-BTP6JNdv.js} +1 -1
  11. package/dist/client/assets/{chunk-7INBJB4K-BNmRJXpH.js → chunk-7INBJB4K-BsVmPyov.js} +1 -1
  12. package/dist/client/assets/{chunk-7M6MHVWA-CqmUCew2.js → chunk-7M6MHVWA-CsHA_fwz.js} +1 -1
  13. package/dist/client/assets/{chunk-7PRAP22T-POpt8059.js → chunk-7PRAP22T-jooxFnA3.js} +1 -1
  14. package/dist/client/assets/{chunk-GTNCS2PH-CGpv_nJF.js → chunk-GTNCS2PH-B4TC-ScJ.js} +1 -1
  15. package/dist/client/assets/{chunk-GWA4HPMP-rku5iuCc.js → chunk-GWA4HPMP-CQHzk-qZ.js} +1 -1
  16. package/dist/client/assets/{chunk-MBY4JIJT-aVv2hMbS.js → chunk-MBY4JIJT-CH5sGI-E.js} +1 -1
  17. package/dist/client/assets/{chunk-NETBCI7D-Vn26OS_d.js → chunk-NETBCI7D-B5tMFrlX.js} +1 -1
  18. package/dist/client/assets/{chunk-O7XYJQB3-CFlDerCD.js → chunk-O7XYJQB3-LPw4VP6e.js} +1 -1
  19. package/dist/client/assets/{chunk-UA2S7LBM-BG-lbrO7.js → chunk-UA2S7LBM-DVU8-vtb.js} +1 -1
  20. package/dist/client/assets/{chunk-WEXAMYUT-DzfflAIJ.js → chunk-WEXAMYUT-Dnrs1Ld4.js} +1 -1
  21. package/dist/client/assets/{chunk-XXDRQBXY-DpTI1BY5.js → chunk-XXDRQBXY-BDPDpedV.js} +1 -1
  22. package/dist/client/assets/{chunk-Z7XXMR3K-C3pZVvEc.js → chunk-Z7XXMR3K-C5ewXtqS.js} +1 -1
  23. package/dist/client/assets/{chunk-ZIGJFQKS-5Tn59Tz_.js → chunk-ZIGJFQKS-C3kX-TWN.js} +1 -1
  24. package/dist/client/assets/{classDiagram-v2-NBCMYWYE-B0Ai_5Sz.js → classDiagram-v2-NBCMYWYE-DS3TfzLh.js} +1 -1
  25. package/dist/client/assets/{core-eaqB-6jU.js → core-C38j58LO.js} +1 -1
  26. package/dist/client/assets/{cose-bilkent-JH36ORCC-yTOAkSBk.js → cose-bilkent-JH36ORCC-DbTnvWg3.js} +1 -1
  27. package/dist/client/assets/{cynefin-OW5HDTMX-C1EbHivx.js → cynefin-OW5HDTMX-BNjAi5zC.js} +1 -1
  28. package/dist/client/assets/{cynefinDiagram-VND7K2PF-W4ejfT-C.js → cynefinDiagram-VND7K2PF-DO7VFekp.js} +1 -1
  29. package/dist/client/assets/{dagre-6A5THRUB-DCLRwyBp.js → dagre-6A5THRUB-_yf_g5Eu.js} +1 -1
  30. package/dist/client/assets/{diagram-22UHCM2B-B2uUz1Sf.js → diagram-22UHCM2B-C_0zfVyF.js} +1 -1
  31. package/dist/client/assets/{diagram-3UASUU5V-C2i6j0gK.js → diagram-3UASUU5V-DSX_Tpmv.js} +1 -1
  32. package/dist/client/assets/{diagram-ATOU4E4O-CGRIsbJn.js → diagram-ATOU4E4O-BjdH8AkF.js} +1 -1
  33. package/dist/client/assets/{diagram-CDSNMT55-CeLMGz-e.js → diagram-CDSNMT55-BiLgPVAJ.js} +1 -1
  34. package/dist/client/assets/{diagram-MLGK6HIB-DV1Yw1yk.js → diagram-MLGK6HIB-BFgscT9R.js} +1 -1
  35. package/dist/client/assets/{diagram-MPIPVDR6-CuFBeKe_.js → diagram-MPIPVDR6-BuoIMiDa.js} +1 -1
  36. package/dist/client/assets/{dist-Cr2gbd4l.js → dist-B77Lw20A.js} +1 -1
  37. package/dist/client/assets/{dist-BTwBvBOz.js → dist-CMYkujym.js} +1 -1
  38. package/dist/client/assets/{ebnfDiagram-ZINNZB2B-4Z9n76nP.js → ebnfDiagram-ZINNZB2B-x4kmvZzD.js} +1 -1
  39. package/dist/client/assets/{elk-276RUBZZ-DA8ZR7dF.js → elk-276RUBZZ-YAyM0RBx.js} +1 -1
  40. package/dist/client/assets/{engine-oniguruma-BmQGvQrV.js → engine-oniguruma-Ds-VbuSq.js} +1 -1
  41. package/dist/client/assets/{erDiagram-OPXOYQCR-CTDqeRLt.js → erDiagram-OPXOYQCR-Bo1yx5ec.js} +1 -1
  42. package/dist/client/assets/eventmodeling-NTZA5JFV-G8nAQ-r0.js +1 -0
  43. package/dist/client/assets/flowDiagram-KWPJA3E3-JYut8MuN.js +1 -0
  44. package/dist/client/assets/{ganttDiagram-FUAMR5RP-Cj9f3Ref.js → ganttDiagram-FUAMR5RP-CIi9ZaVr.js} +1 -1
  45. package/dist/client/assets/{gitGraph-4MIJSDKK-B3FiLaE0.js → gitGraph-4MIJSDKK-DPr2GO72.js} +1 -1
  46. package/dist/client/assets/{gitGraphDiagram-X574FWY7-DPZfXx_L.js → gitGraphDiagram-X574FWY7-8akAig1Y.js} +1 -1
  47. package/dist/client/assets/index-ClMx9yVg.css +1 -0
  48. package/dist/client/assets/{index-Cqenoz2e.js → index-IIP4HzAT.js} +6 -6
  49. package/dist/client/assets/{info-A6RAGUB7-BAlSTvkv.js → info-A6RAGUB7-Gtb-Ecti.js} +1 -1
  50. package/dist/client/assets/{infoDiagram-VRGFBTTK-CbGiCy3i.js → infoDiagram-VRGFBTTK-CautEhHX.js} +1 -1
  51. package/dist/client/assets/{ishikawaDiagram-OU5B5YK6-HwD-zBAB.js → ishikawaDiagram-OU5B5YK6-C8BUCcyV.js} +1 -1
  52. package/dist/client/assets/{journeyDiagram-ZHPQQLJL-CjmNA7v_.js → journeyDiagram-ZHPQQLJL-BA5WG8Xf.js} +1 -1
  53. package/dist/client/assets/{kanban-definition-PNTS6WVX-DKiLBA-v.js → kanban-definition-PNTS6WVX-DRXzEJBa.js} +1 -1
  54. package/dist/client/assets/{line-QNZCtL87.js → line-DAcfMF01.js} +1 -1
  55. package/dist/client/assets/{linear-Cimo_Ktj.js → linear-uYi6Pah9.js} +1 -1
  56. package/dist/client/assets/{mermaid-parser.core-BrIOn0_H.js → mermaid-parser.core-CUupN43F.js} +3 -3
  57. package/dist/client/assets/{mermaid.core-DP4c5AXa.js → mermaid.core-P7Zn0OkI.js} +4 -4
  58. package/dist/client/assets/{mindmap-definition-NLK3R4M7-99gdOEjC.js → mindmap-definition-NLK3R4M7-Bn4VqIyk.js} +1 -1
  59. package/dist/client/assets/{packet-AYTQ26CC-BxNPQbmA.js → packet-AYTQ26CC-CCcEthJT.js} +1 -1
  60. package/dist/client/assets/{pegDiagram-GJSIUBJH-DcB3-w2f.js → pegDiagram-GJSIUBJH-BD1vaxu_.js} +1 -1
  61. package/dist/client/assets/{pie-WAS4IAKB-C8IolWbl.js → pie-WAS4IAKB-DJrFAJNb.js} +1 -1
  62. package/dist/client/assets/{pieDiagram-5QR66LMP-CI7UHyLf.js → pieDiagram-5QR66LMP-BHamJTzC.js} +1 -1
  63. package/dist/client/assets/{quadrantDiagram-O4NWA36T-B5M09rwy.js → quadrantDiagram-O4NWA36T-Co7yTeQ3.js} +1 -1
  64. package/dist/client/assets/{radar-RG4KPBEZ-BWLNOZQF.js → radar-RG4KPBEZ-C2VAxB0O.js} +1 -1
  65. package/dist/client/assets/{railroad-74A4TZTK-BBgrDybk.js → railroad-74A4TZTK-dcSfLPuR.js} +1 -1
  66. package/dist/client/assets/railroad-abnf-HS5TGJTU-CZqf5C4_.js +1 -0
  67. package/dist/client/assets/railroad-ebnf-LZEXJU2U-BkzQPC_g.js +1 -0
  68. package/dist/client/assets/railroad-peg-WCYAUIDC-CnjsL3Wl.js +1 -0
  69. package/dist/client/assets/{railroadDiagram-XR7U4H2S-DfLKmOOV.js → railroadDiagram-XR7U4H2S-B2dydE7a.js} +1 -1
  70. package/dist/client/assets/{requirementDiagram-PLB6GJNP-BRfCLMIV.js → requirementDiagram-PLB6GJNP-orHF7QGe.js} +1 -1
  71. package/dist/client/assets/{sankeyDiagram-IPEJSGJF-L0OovUCE.js → sankeyDiagram-IPEJSGJF-C_OsMuGS.js} +1 -1
  72. package/dist/client/assets/{sequenceDiagram-PO4LG4MO-DihY5-ud.js → sequenceDiagram-PO4LG4MO-Dh6-7-gO.js} +1 -1
  73. package/dist/client/assets/{src-Dra0Xg0O.js → src-CoUI9Pvh.js} +1 -1
  74. package/dist/client/assets/{stateDiagram-v2-GCMORJYK-BL_hIu6k.js → stateDiagram-v2-GCMORJYK-CIs80eMe.js} +1 -1
  75. package/dist/client/assets/{swimlanes-2SLR337P-ChQabuby.js → swimlanes-2SLR337P-Dwo3Yt9h.js} +1 -1
  76. package/dist/client/assets/swimlanesDiagram-TC7HE7FX-CINzeMsu.js +8 -0
  77. package/dist/client/assets/{timeline-definition-EJHVYXUP-BAK3-LpH.js → timeline-definition-EJHVYXUP-Bbz9sh3O.js} +1 -1
  78. package/dist/client/assets/{treeView-Q6P3EWNA-ul5oNNwQ.js → treeView-Q6P3EWNA-HHdzOu-n.js} +1 -1
  79. package/dist/client/assets/{treemap-WGGIJYW6-N09mB4mw.js → treemap-WGGIJYW6-Bc3AMsxh.js} +1 -1
  80. package/dist/client/assets/{usecaseDiagram-POWQR4AR-CKjVj1WA.js → usecaseDiagram-POWQR4AR-Dx1EDbri.js} +1 -1
  81. package/dist/client/assets/{vennDiagram-UO4OBE2U-BJk8NCzk.js → vennDiagram-UO4OBE2U-DvMMdO42.js} +1 -1
  82. package/dist/client/assets/{wardley-WFR3VGLG-C79BQavk.js → wardley-WFR3VGLG-BqMvXOfu.js} +1 -1
  83. package/dist/client/assets/{wardleyDiagram-VNRHLVJA-Dhj3Ep_D.js → wardleyDiagram-VNRHLVJA-CX0grRSr.js} +1 -1
  84. package/dist/client/assets/{xychartDiagram-PMCCYNJV-cJRwPI4L.js → xychartDiagram-PMCCYNJV-BQQA3oHd.js} +1 -1
  85. package/dist/client/index.html +2 -2
  86. package/package.json +1 -1
  87. package/plugin.json +1 -1
  88. package/dist/client/assets/architecture-7GRP2DOG-DRh1anq7.js +0 -1
  89. package/dist/client/assets/channel-DgyVhp45.js +0 -1
  90. package/dist/client/assets/eventmodeling-NTZA5JFV-DOK7jJK9.js +0 -1
  91. package/dist/client/assets/flowDiagram-KWPJA3E3-p353nqex.js +0 -1
  92. package/dist/client/assets/index-BH1cCDEv.css +0 -1
  93. package/dist/client/assets/railroad-abnf-HS5TGJTU-CrBkmUeQ.js +0 -1
  94. package/dist/client/assets/railroad-ebnf-LZEXJU2U-Bxiu0IjD.js +0 -1
  95. package/dist/client/assets/railroad-peg-WCYAUIDC-DsYmbwPf.js +0 -1
  96. package/dist/client/assets/swimlanesDiagram-TC7HE7FX-0xAZLtPg.js +0 -8
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-DP4c5AXa.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-Dra0Xg0O.js","assets/chunk-O7XYJQB3-CFlDerCD.js","assets/chunk-ZIGJFQKS-5Tn59Tz_.js","assets/dist-BTwBvBOz.js","assets/chunk-742MDFTN-C6HG0C5O.js","assets/chunk-MBY4JIJT-aVv2hMbS.js","assets/chunk-DUW6YSOI-Dgx8z5s3.js","assets/chunk-7PRAP22T-POpt8059.js","assets/chunk-7INBJB4K-BNmRJXpH.js","assets/chunk-J5ZVWO5B-oDCd-gWO.js","assets/rough.esm-Dy-Kn_BL.js","assets/chunk-5DYCD2WN-wrFKk0N8.js","assets/chunk-Z7XXMR3K-C3pZVvEc.js","assets/line-QNZCtL87.js","assets/path-fybaL0A-.js","assets/array-BifhSqXX.js","assets/chunk-UA2S7LBM-BG-lbrO7.js","assets/c-DWGmR78Y.js","assets/c-SSSlmE39.js","assets/cpp-CJIxL8VH.js","assets/cpp-Cts1PyIS.js","assets/css-DUjzNfgv.js","assets/css-BGIxQoYs.js","assets/html-BlpXnbzK.js","assets/html-BMn1ogTm.js","assets/javascript-BzbQS41l.js","assets/java-DxlWrXwe.js","assets/java-BtIQNnN0.js","assets/javascript-Yelw-5ZN.js","assets/json-CaljABEy.js","assets/json-B88Oqtu5.js","assets/jsx-hEbJ82HF.js","assets/jsx-D3KKoC5L.js","assets/php-CUj1wjLQ.js","assets/xml-WY0zc4PG.js","assets/sql-CNu3Or2W.js","assets/ruby-DgJVzwN8.js","assets/typescript-j_1H8WHN.js","assets/tsx-BOvsFOI6.js","assets/shellscript-CqHdAlCp.js","assets/yaml-DijMHRDA.js","assets/scss-8bKmll0B.js","assets/shellscript-BiGZg9Om.js","assets/sql-BOsskAmu.js","assets/svelte-DAcAPYhA.js","assets/tsx-5f3ulCja.js","assets/typescript-Utq2Cl8c.js","assets/vue-rALd9gPk.js","assets/xml-CoDIzWF0.js","assets/yaml-CxbubiML.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-P7Zn0OkI.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-CoUI9Pvh.js","assets/chunk-O7XYJQB3-LPw4VP6e.js","assets/chunk-ZIGJFQKS-C3kX-TWN.js","assets/dist-CMYkujym.js","assets/chunk-742MDFTN-BTP6JNdv.js","assets/chunk-MBY4JIJT-CH5sGI-E.js","assets/chunk-DUW6YSOI-Dgx8z5s3.js","assets/chunk-7PRAP22T-jooxFnA3.js","assets/chunk-7INBJB4K-BsVmPyov.js","assets/chunk-J5ZVWO5B-oDCd-gWO.js","assets/rough.esm-Dy-Kn_BL.js","assets/chunk-5DYCD2WN-BmQXtfyC.js","assets/chunk-Z7XXMR3K-C5ewXtqS.js","assets/line-DAcfMF01.js","assets/path-fybaL0A-.js","assets/array-BifhSqXX.js","assets/chunk-UA2S7LBM-DVU8-vtb.js","assets/c-DWGmR78Y.js","assets/c-SSSlmE39.js","assets/cpp-CJIxL8VH.js","assets/cpp-Cts1PyIS.js","assets/css-DUjzNfgv.js","assets/css-BGIxQoYs.js","assets/html-BlpXnbzK.js","assets/html-BMn1ogTm.js","assets/javascript-BzbQS41l.js","assets/java-DxlWrXwe.js","assets/java-BtIQNnN0.js","assets/javascript-Yelw-5ZN.js","assets/json-CaljABEy.js","assets/json-B88Oqtu5.js","assets/jsx-hEbJ82HF.js","assets/jsx-D3KKoC5L.js","assets/php-CUj1wjLQ.js","assets/xml-WY0zc4PG.js","assets/sql-CNu3Or2W.js","assets/ruby-DgJVzwN8.js","assets/typescript-j_1H8WHN.js","assets/tsx-BOvsFOI6.js","assets/shellscript-CqHdAlCp.js","assets/yaml-DijMHRDA.js","assets/scss-8bKmll0B.js","assets/shellscript-BiGZg9Om.js","assets/sql-BOsskAmu.js","assets/svelte-DAcAPYhA.js","assets/tsx-5f3ulCja.js","assets/typescript-Utq2Cl8c.js","assets/vue-rALd9gPk.js","assets/xml-CoDIzWF0.js","assets/yaml-CxbubiML.js"])))=>i.map(i=>d[i]);
2
2
  var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n)),u=(e=>typeof require<`u`?require:typeof Proxy<`u`?new Proxy(e,{get:(e,t)=>(typeof require<`u`?require:e)[t]}):e)(function(e){if(typeof require<`u`)return require.apply(this,arguments);throw Error('Calling `require` for "'+e+"\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.")});(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var d=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function A(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var j=/\/+/g;function M(e,t){return typeof e==`object`&&e&&e.key!=null?A(``+e.key):t.toString(36)}function N(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function P(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,P(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+M(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(j,`$&/`)+`/`),P(o,r,i,``,function(e){return e})):o!=null&&(k(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(j,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u<e.length;u++)a=e[u],s=l+M(a,u),c+=P(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+M(a,u++),c+=P(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return P(N(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function F(e,t,n){if(e==null)return e;var r=[],i=0;return P(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function I(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var ee=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)};function te(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,ee)}catch(e){ee(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function ne(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else te(ne.bind(null,e))}var L={map:F,forEach:function(e,t,n){F(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return F(e,function(){t++}),t},toArray:function(e){return F(e,function(e){return e})||[]},only:function(e){if(!k(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=L,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=ne,e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!E.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return D(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)E.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return D(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=k,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:I}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=te,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.0`})),f=o(((e,t)=>{t.exports=d()})),p=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),m=o(((e,t)=>{t.exports=p()})),h=o((e=>{var t=f();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.browser=function(e){return{$$typeof:o,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=u(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=u(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.0`})),g=o(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=h()})),_=o((e=>{var t=m(),n=f(),r=g();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}function p(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&p(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function h(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function _(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function v(e){var t=[null,null],n=h(e);return n===null||y(t,e,n.child,{foundSelf:!1}),t}function y(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&y(e,t,n.child,r))return!0;n=n.sibling}return!1}function b(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var x=null,S=null;function C(e,t,n){return e===n||e===t&&(x=e,!0)}function w(e,t,n){return e===n?(S=e,!1):e===t&&(S!==null&&(x=e),!0)}function T(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function E(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var D=Object.assign,O=Symbol.for(`react.element`),k=Symbol.for(`react.transitional.element`),A=Symbol.for(`react.portal`),j=Symbol.for(`react.fragment`),M=Symbol.for(`react.strict_mode`),N=Symbol.for(`react.profiler`),P=Symbol.for(`react.consumer`),F=Symbol.for(`react.context`),I=Symbol.for(`react.forward_ref`),ee=Symbol.for(`react.suspense`),te=Symbol.for(`react.suspense_list`),ne=Symbol.for(`react.memo`),L=Symbol.for(`react.lazy`),re=Symbol.for(`react.activity`),ie=Symbol.for(`react.legacy_hidden`),ae=Symbol.for(`react.memo_cache_sentinel`),oe=Symbol.for(`react.view_transition`),se=Symbol.for(`react.recoverable`),ce=Symbol.iterator;function le(e){return typeof e!=`object`||!e?null:(e=ce&&e[ce]||e[`@@iterator`],typeof e==`function`?e:null)}var ue=Symbol.for(`react.client.reference`);function de(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ue?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case j:return`Fragment`;case N:return`Profiler`;case M:return`StrictMode`;case ee:return`Suspense`;case te:return`SuspenseList`;case re:return`Activity`;case oe:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case A:return`Portal`;case F:return e.displayName||`Context`;case P:return(e._context.displayName||`Context`)+`.Consumer`;case I:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ne:return t=e.displayName||null,t===null?de(e.type)||`Memo`:t;case L:t=e._payload,e=e._init;try{return de(e(t))}catch{}}return null}var R=Array.isArray,z=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,fe={pending:!1,data:null,method:null,action:null},pe=[],me=-1;function he(e){return{current:e}}function ge(e){0>me||(e.current=pe[me],pe[me]=null,me--)}function _e(e,t){me++,pe[me]=e.current,e.current=t}var ve=he(null),ye=he(null),be=he(null),xe=he(null);function Se(e,t){switch(_e(be,t),_e(ye,e),_e(ve,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ge(ve),_e(ve,e)}function Ce(){ge(ve),ge(ye),ge(be)}function we(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,_e(xe,e)),t=ve.current;var n=dp(t,e.type);t!==n&&(_e(ye,e),_e(ve,n))}function Te(e){ye.current===e&&(ge(ve),ge(ye)),xe.current===e&&(ge(xe),sh._currentValue=fe)}var Ee,De;function V(e){if(Ee===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Ee=t&&t[1]||``,De=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+Ee+e+De}var Oe=!1;function ke(e,t){if(!e||Oe)return``;Oe=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
@@ -76,18 +76,18 @@ ${this.parser.parse(e)}</blockquote>
76
76
  ${e}</tr>
77
77
  `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
78
78
  `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Li(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,text:n,tokens:r,autolink:i}){let a=i?Li(n,!0):this.parser.parseInline(r),o=zi(e);if(o===null)return a;e=Li(o,i);let s=`<a href="`+e+`"`;return t&&(s+=` title="`+Li(t)+`"`),s+=`>`+a+`</a>`,s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=zi(e);if(i===null)return Li(n);e=i;let a=`<img src="${Li(e)}" alt="${Li(n)}"`;return t&&(a+=` title="${Li(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:Li(e.text)}},q=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},Qi=class e{options;renderer;textRenderer;constructor(e){this.options=e||mr,this.options.renderer=this.options.renderer||new Zi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new q}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`checkbox`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`checkbox`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},$i=class{options;block;constructor(e){this.options=e||mr}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Xi.lex:Xi.lexInline}provideParser(e=this.block){return e?Qi.parse:Qi.parseInline}},ea=new class{defaults=pr();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Qi;Renderer=Zi;TextRenderer=q;Lexer=Xi;Tokenizer=Yi;Hooks=$i;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new Zi(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Yi(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new $i;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=$i.passThroughHooks.has(n)?e=>{if(this.defaults.async&&$i.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Xi.lex(e,t??this.defaults)}parser(e,t){return Qi.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?Xi.lex:Xi.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?Qi.parse:Qi.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?Xi.lex:Xi.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?Qi.parse:Qi.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
79
- Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+Li(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function J(e,t){return ea.parse(e,t)}J.options=J.setOptions=function(e){return ea.setOptions(e),J.defaults=ea.defaults,hr(J.defaults),J},J.getDefaults=pr,J.defaults=mr;function ta(...e){return ea.use(...e),J.defaults=ea.defaults,hr(J.defaults),J}J.use=ta,J.walkTokens=function(e,t){return ea.walkTokens(e,t)},J.parseInline=ea.parseInline,J.Parser=Qi,J.parser=Qi.parse,J.Renderer=Zi,J.TextRenderer=q,J.Lexer=Xi,J.lexer=Xi.lex,J.Tokenizer=Yi,J.Hooks=$i,J.parse=J,J.options,J.setOptions,J.walkTokens,J.parseInline,Qi.parse,Xi.lex,J.setOptions({gfm:!0,breaks:!0});var na=[`p`,`br`,`hr`,`strong`,`em`,`del`,`code`,`pre`,`blockquote`,`ul`,`ol`,`li`,`a`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`table`,`thead`,`tbody`,`tr`,`th`,`td`],ra=fr(),ia=!1;function aa(){ia||(ia=!0,ra.addHook(`afterSanitizeAttributes`,e=>{if(e instanceof Element&&(e.tagName===`A`&&e.hasAttribute(`href`)&&!(e.getAttribute(`href`)??``).startsWith(`#`)&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`)),e.hasAttribute(`class`))){let t=/^language-[\w+-]+$/.exec(e.getAttribute(`class`)??``);e.tagName===`CODE`&&t?e.setAttribute(`class`,t[0]):e.removeAttribute(`class`)}}))}function oa(e){aa();let t=J.parse(e,{async:!1});return ra.sanitize(t,{ALLOWED_TAGS:na,ALLOWED_ATTR:[`href`,`title`,`target`,`rel`,`class`],ALLOWED_URI_REGEXP:/^(?:https?:|mailto:|#)/i})}var sa=[...na,`img`,`picture`,`source`,`div`,`span`,`details`,`summary`],ca=fr(),la=``;function ua(e,t){let n=t.split(/[?#]/,1)[0]??``,r=n.startsWith(`/`)?n.slice(1):e?`${e}/${n}`:n,i=[];for(let e of r.split(`/`))e!==``&&e!==`.`&&(e===`..`?i.pop():i.push(e));return i.join(`/`)}function da(e){return`/api/file?path=${encodeURIComponent(ua(la,e))}&side=head`}var fa=/^(?:[a-z][a-z0-9+.-]*:|\/\/|#)/i,pa=/^(?:https?:|mailto:|#)/i,ma=!1;function ha(){ma||(ma=!0,ca.addHook(`uponSanitizeAttribute`,(e,t)=>{let{attrName:n,attrValue:r}=t;n===`src`||n===`href`?fa.test(r)?pa.test(r)||(t.keepAttr=!1):t.attrValue=da(r):n===`srcset`&&(t.attrValue=r.split(`,`).map(e=>{let[t,...n]=e.trim().split(/\s+/);return t?fa.test(t)?pa.test(t)?[t,...n].join(` `):``:[da(t),...n].join(` `):``}).filter(Boolean).join(`, `))}),ca.addHook(`afterSanitizeAttributes`,e=>{if(e instanceof Element&&(e.tagName===`A`&&e.hasAttribute(`href`)&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`)),e.hasAttribute(`class`))){let t=/^language-[\w+-]+$/.exec(e.getAttribute(`class`)??``);e.tagName===`CODE`&&t?e.setAttribute(`class`,t[0]):e.removeAttribute(`class`)}}))}function ga(e,t){ha();let n=t.lastIndexOf(`/`);la=n===-1?``:t.slice(0,n);let r=J.parse(e,{async:!1});return ca.sanitize(r,{ALLOWED_TAGS:sa,ALLOWED_ATTR:[`href`,`title`,`target`,`rel`,`class`,`src`,`srcset`,`alt`,`width`,`height`,`media`,`align`,`open`]})}function _a(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);if(Number.isNaN(n))return e;let r=Math.round((t-n)/1e3);if(r<45)return`just now`;let i=Math.round(r/60);if(i<60)return`${i} minute${i===1?``:`s`} ago`;let a=Math.round(i/60);if(a<24)return`${a} hour${a===1?``:`s`} ago`;let o=Math.round(a/24);return o<7?`${o} day${o===1?``:`s`} ago`:new Date(n).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function va(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);if(Number.isNaN(n))return``;let r=Math.max(0,Math.round((t-n)/1e3));if(r<60)return`${r}s`;let i=Math.round(r/60);if(i<60)return`${i}m`;let a=Math.round(i/60);if(a<24)return`${a}h`;let o=Math.round(a/24);return o<7?`${o}d`:new Date(n).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}var ya=30,ba=22,xa=48,Sa=1100,Ca=1500,wa=1.1,Ta=3e3,Ea=110,Da=560,Oa=64,ka=90/24,Aa=ya*3.5/24,ja=540/24,Ma={shut:`M7.8 10.4h2.4M13.8 10.4h2.4`,plus:`M7.8 10.2h2.4M9 9v2.4M13.8 10.2h2.4M15 9v2.4`,happy:`M7.8 11l1.2-1.4 1.2 1.4M13.8 11l1.2-1.4 1.2 1.4`},Na=new Set([`stand`,`sit`]);function Pa(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}var Fa=(e,t)=>e+Math.random()*(t-e),Ia=e=>`translate(${e.x}px, ${e.y}px) scale(${e.s})`;function La({presence:e,reason:t,seat:n,onAway:r,summon:i=0}){let a=(0,x.useRef)(null),o=(0,x.useRef)(null),[s,c]=(0,x.useState)(!1),l=(0,x.useRef)(!1),u=(0,x.useRef)(r);u.current=r;let d=(0,x.useCallback)(e=>{l.current=e,c(e),u.current?.(e)},[]),[f,p]=(0,x.useState)(!1),m=(0,x.useRef)(null),h=(0,x.useRef)(0),g=(0,x.useRef)(!1),_=(0,x.useRef)(i),[v,y]=(0,x.useState)(0),[b,C]=(0,x.useState)(null),[w,T]=(0,x.useState)(null),[E,D]=(0,x.useState)(`stand`),[O,k]=(0,x.useState)(null),A=(0,x.useRef)(null);A.current=b;let[j,M]=(0,x.useState)(!1),N=(0,x.useRef)(!1);N.current=j;let[P,F]=(0,x.useState)(!1);(0,x.useEffect)(()=>{let e,t=t=>{N.current||M(!0),t.type===`keydown`&&F(!0),clearTimeout(e),e=setTimeout(()=>{M(!1),F(!1)},Ta)},n={capture:!0,passive:!0},r=[`pointermove`,`wheel`,`scroll`,`keydown`];for(let e of r)addEventListener(e,t,n);return()=>{clearTimeout(e);for(let e of r)removeEventListener(e,t,n)}},[]),(0,x.useEffect)(()=>{let e=a.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(([e])=>e&&y(e.contentRect.width));return t.observe(e),()=>t.disconnect()},[]);let I=(0,x.useRef)(t);(0,x.useEffect)(()=>{t===`replied`&&I.current!==`replied`&&!Pa()&&k(`approve`),I.current=t},[t]);let ee=Na.has(E)&&!O;(0,x.useEffect)(()=>{let e=o.current,t=e?.querySelector(`.critter-look`);if(!e||!t)return;if(!ee||Pa()){t.style.transform=``;return}let n=0,r=r=>{n||=requestAnimationFrame(()=>{n=0;let i=e.getBoundingClientRect(),a=r.clientX-(i.left+i.width/2),o=r.clientY-(i.top+i.height*.4),s=Math.hypot(a,o)||1;t.style.transform=`translate(${a/s*wa}px, ${o/s*wa*.8}px)`})};return addEventListener(`pointermove`,r),()=>{removeEventListener(`pointermove`,r),cancelAnimationFrame(n),t.style.transform=``}},[ee]);let te=Math.max(0,v-ya),ne=(0,x.useRef)(te);ne.current=te;let L=v>0,re=e===`waiting`||te<Oa||Pa();(0,x.useEffect)(()=>()=>u.current?.(!1),[]),(0,x.useLayoutEffect)(()=>{!s&&m.current&&(m.current.anim.cancel(),m.current=null)},[s]),(0,x.useEffect)(()=>{if(!L)return;let t=()=>ne.current,r,s=!0,c=()=>Math.min(A.current??t(),t()),u=(e,t)=>{r=setTimeout(()=>s&&t(),e)},f=(e,t,n)=>{D(e),u(t,n)},v=(e,t,n)=>{let r=c(),i=Math.abs(e-r)/t*1e3;if(i<150){n();return}D(`walk`),T({ms:i,dir:e<r?`left`:`right`}),C(e),u(i,()=>{T(null),n()})},y=()=>{let e=n?.current?n.current.getBoundingClientRect():void 0,t=a.current?.getBoundingClientRect(),r=o.current;if(!e?.width||!t||!r)return null;let i=e.width/ja;return{x:e.left-t.left-ka*i,y:e.top+e.height/30-t.top-r.offsetTop-Aa*i,s:i}},b=(e,t,n,r)=>{let i=o.current;if(!i||typeof i.animate!=`function`){r();return}let a={x:(e.x+t.x)/2,y:Math.min(e.y,t.y)-16,s:(e.s+t.s)/2},s=i.animate([e,a,t].map(e=>({transform:Ia(e)})),{duration:Da,easing:`cubic-bezier(0.3, 0.7, 0.4, 1)`,fill:`forwards`});m.current={anim:s,home:n},u(Da,r)},x=()=>{p(!1),d(!1)},S=e=>{v(t(),Ea,()=>{let t=y();if(!t){x(),e?.();return}D(`stand`),p(!0),b({x:c(),y:0,s:1},t,!0,()=>{x(),e?.()})})},w=e=>{let n=y();if(C(t()),D(`stand`),p(!0),d(!0),!n){p(!1),e();return}b(n,{x:t(),y:0,s:1},!1,()=>{m.current?.anim.cancel(),m.current=null,p(!1),e()})},E=()=>{if(e===`working`){let e=()=>c()>t()/2?Fa(0,t()*.4):Fa(t()*.6,t()),n=()=>Math.random()<.5?`inspect`:`write`,r=()=>N.current?f(n(),Fa(2500,4e3),r):v(e(),xa,()=>f(n(),Fa(2500,5e3),()=>Math.random()<.4?f(`think`,Fa(1500,2800),r):r()));f(n(),Fa(1500,3e3),r)}else{let e=()=>{let n=Math.random();N.current?f(n<.5?`stand`:`read`,Fa(3e3,6e3),e):n<.3?f(`read`,Fa(4e3,8e3),e):n<.5?f(`stand`,Fa(3e3,6e3),e):n<.75?v(Fa(0,t()),ba,e):n<.9?f(`sit`,Fa(4e3,8e3),e):f(`think`,Fa(2e3,3500),e)};f(`read`,Fa(3e3,5e3),e)}},j=()=>u(Math.max(e===`working`?Fa(300,700):Fa(1e3,2500),h.current-Date.now()),()=>w(E)),M=i!==_.current;if(_.current=i,M&&!O&&!re&&!l.current)w(()=>k(`poke`));else if(M&&!O&&l.current)k(`poke`);else if(O&&l.current)f(O,O===`poke`?Sa:Ca,()=>{O===`approve`&&(g.current=!0),k(null)});else if(O)k(null);else if(re)l.current&&!Pa()?S():l.current&&x(),D(e===`waiting`?`sleep`:`stand`);else if(l.current&&(P||g.current)){let e=g.current;g.current=!1,e&&(h.current=Date.now()+Fa(4e3,6e3)),S(P?void 0:j)}else l.current?E():(D(`stand`),P||j());return()=>{if(s=!1,clearTimeout(r),m.current){let{anim:e,home:t}=m.current;e.cancel(),m.current=null,p(!1),t&&d(!1),T(null);return}let e=o.current;if(e)try{C(new DOMMatrixReadOnly(getComputedStyle(e).transform).m41)}catch{}T(null)}},[e,L,O,P,re,n,d,i]);let ie=()=>{!O&&!Pa()&&k(`poke`)},ae={transform:Ia({x:Math.min(b??te,te),y:0,s:1}),transition:w?`transform ${w.ms}ms linear`:`none`,visibility:v&&s?void 0:`hidden`};return(0,S.jsx)(`span`,{className:`critter-track`,ref:a,children:(0,S.jsx)(`span`,{ref:o,className:`critter-walker${w?` critter-moving critter-${w.dir}`:``}${j?` critter-calm`:``}${f?` critter-tucked`:``}`,style:ae,onPointerEnter:ie,children:(0,S.jsx)(Ra,{presence:e,act:E})})})}function Ra({presence:e,act:t=e===`waiting`?`sleep`:`stand`,size:n=ya}){return(0,S.jsxs)(`svg`,{className:`critter critter-${e} critter-act-${t}`,width:n,height:n,viewBox:`0 0 24 24`,"aria-hidden":`true`,focusable:`false`,children:[(0,S.jsxs)(`g`,{className:`critter-figure`,children:[(0,S.jsx)(`rect`,{className:`critter-leg critter-leg-l`,x:`7`,y:`16.5`,width:`3`,height:`4.5`,rx:`1`}),(0,S.jsx)(`rect`,{className:`critter-leg critter-leg-r`,x:`14`,y:`16.5`,width:`3`,height:`4.5`,rx:`1`}),(0,S.jsxs)(`g`,{className:`critter-torso`,children:[(0,S.jsx)(`rect`,{className:`critter-body`,x:`3`,y:`3.5`,width:`18`,height:`14`,rx:`4`}),(0,S.jsxs)(`g`,{className:`critter-look`,children:[(0,S.jsx)(`path`,{className:`critter-eyes critter-eyes-shut`,d:Ma.shut}),(0,S.jsxs)(`g`,{className:`critter-eyes-open`,children:[(0,S.jsx)(`rect`,{x:`8.1`,y:`8.6`,width:`1.8`,height:`3.1`,rx:`0.9`}),(0,S.jsx)(`rect`,{x:`14.1`,y:`8.6`,width:`1.8`,height:`3.1`,rx:`0.9`})]}),(0,S.jsx)(`path`,{className:`critter-eyes critter-eyes-plus`,d:Ma.plus}),(0,S.jsx)(`path`,{className:`critter-eyes critter-eyes-happy`,d:Ma.happy})]}),(0,S.jsxs)(`g`,{className:`critter-glasses`,children:[(0,S.jsx)(`circle`,{cx:`9`,cy:`10.2`,r:`3`}),(0,S.jsx)(`circle`,{cx:`15`,cy:`10.2`,r:`3`})]})]}),(0,S.jsxs)(`g`,{className:`critter-page`,children:[(0,S.jsx)(`rect`,{x:`6.2`,y:`13.2`,width:`11.6`,height:`7`,rx:`1`}),(0,S.jsx)(`path`,{className:`critter-line-del`,d:`M8 15.1h4`}),(0,S.jsx)(`path`,{className:`critter-line-ctx`,d:`M8 16.7h6.5`}),(0,S.jsx)(`path`,{className:`critter-line-add`,pathLength:`1`,d:`M8 18.3h5.5`})]}),(0,S.jsxs)(`g`,{className:`critter-hands`,children:[(0,S.jsx)(`circle`,{cx:`6.2`,cy:`17`,r:`1.4`}),(0,S.jsx)(`circle`,{cx:`17.8`,cy:`17`,r:`1.4`})]}),(0,S.jsxs)(`g`,{className:`critter-pen`,children:[(0,S.jsx)(`path`,{d:`M14.6 19l3.4-3.6`}),(0,S.jsx)(`circle`,{cx:`18.3`,cy:`15.3`,r:`1.4`})]}),(0,S.jsxs)(`g`,{className:`critter-mag`,children:[(0,S.jsx)(`circle`,{className:`critter-lens`,cx:`21.6`,cy:`13.4`,r:`3`}),(0,S.jsx)(`path`,{d:`M23.7 15.6l2 2`}),(0,S.jsx)(`circle`,{className:`critter-mag-hand`,cx:`25.8`,cy:`17.7`,r:`1.4`})]})]}),(0,S.jsxs)(`g`,{className:`critter-z`,children:[(0,S.jsx)(`path`,{className:`critter-z-a`,d:`M17.5 0.5h3l-3 3h3`}),(0,S.jsx)(`path`,{className:`critter-z-b`,d:`M21.5 -4.5h4l-4 4h4`})]}),(0,S.jsxs)(`g`,{className:`critter-thought`,children:[(0,S.jsx)(`circle`,{cx:`20.5`,cy:`2.6`,r:`0.9`}),(0,S.jsx)(`circle`,{cx:`22.6`,cy:`0.2`,r:`1.15`}),(0,S.jsx)(`circle`,{cx:`25.2`,cy:`-2.6`,r:`1.4`})]}),(0,S.jsx)(`path`,{className:`critter-spark critter-spark-a`,d:`M19.5 1.5h2.4M20.7 0.3v2.4`}),(0,S.jsx)(`path`,{className:`critter-spark critter-spark-b`,d:`M2.5 2.5h2.4M3.7 1.3v2.4`}),(0,S.jsxs)(`g`,{className:`critter-badge`,children:[(0,S.jsx)(`circle`,{cx:`12`,cy:`-2.5`,r:`3`}),(0,S.jsx)(`path`,{d:`M10.6 -2.5l1 1 1.9-2`})]})]})}function za({eyes:e}){return(0,S.jsxs)(`svg`,{className:`critter-face`,width:`18`,height:`15`,viewBox:`3 3 18 15`,"aria-hidden":`true`,focusable:`false`,children:[(0,S.jsx)(`rect`,{x:`3`,y:`3.5`,width:`18`,height:`14`,rx:`4`}),e===`open`?(0,S.jsxs)(`g`,{className:`critter-face-open`,children:[(0,S.jsx)(`rect`,{x:`8.1`,y:`8.6`,width:`1.8`,height:`3.1`,rx:`0.9`}),(0,S.jsx)(`rect`,{x:`14.1`,y:`8.6`,width:`1.8`,height:`3.1`,rx:`0.9`})]}):(0,S.jsx)(`path`,{className:`critter-face-eyes`,d:Ma[e]})]})}function Ba({size:e=24,className:t,label:n}){return(0,S.jsx)(`svg`,{className:t?`icon living-mark ${t}`:`icon living-mark`,width:e,height:e,viewBox:`0 0 24 24`,focusable:`false`,"aria-hidden":!n||void 0,role:n?`img`:void 0,"aria-label":n,children:(0,S.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,children:[(0,S.jsx)(`path`,{className:`lm-minus`,d:`M3.3 7.4h2.6`}),(0,S.jsx)(`path`,{className:`lm-plus-h`,d:`M3.3 16.6h2.6`}),(0,S.jsx)(`path`,{className:`lm-plus-v`,d:`M4.6 15.3v2.6`}),(0,S.jsx)(`path`,{className:`lm-l1`,d:`M9.3 7.4H20.4`}),(0,S.jsx)(`path`,{d:`M9.3 12h8`}),(0,S.jsx)(`path`,{className:`lm-l3`,d:`M9.3 16.6h10.2`})]})})}function Va({label:e,icon:t=`more`,children:n,align:r=`right`,triggerClassName:i=`btn btn-ghost btn-icon btn-sm`}){let[a,o]=(0,x.useState)(!1),s=(0,x.useRef)(null);return(0,x.useEffect)(()=>{if(!a)return;let e=e=>{s.current?.contains(e.target)||o(!1)},t=e=>{e.key===`Escape`&&(e.stopPropagation(),o(!1))};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t,!0),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t,!0)}},[a]),(0,S.jsxs)(`div`,{className:`menu`,ref:s,children:[(0,S.jsx)(`button`,{type:`button`,className:i,"aria-label":e,"data-tip":a?void 0:e,"aria-haspopup":`menu`,"aria-expanded":a,onClick:e=>{e.stopPropagation(),o(e=>!e)},children:(0,S.jsx)(U,{name:t})}),a&&(0,S.jsx)(`div`,{className:`menu-panel${r===`left`?` menu-panel-left`:``}`,role:`menu`,children:n(()=>o(!1))})]})}function Ha({icon:e,kbd:t,checked:n,danger:r=!1,onClick:i,children:a}){return(0,S.jsxs)(`button`,{type:`button`,role:n===void 0?`menuitem`:`menuitemradio`,...n===void 0?{}:{"aria-checked":n},className:`menu-item${r?` menu-item-danger`:``}`,onClick:i,children:[e&&(0,S.jsx)(U,{name:e,size:`sm`}),(0,S.jsx)(`span`,{className:`menu-item-label`,children:a}),n&&(0,S.jsx)(U,{name:`check`,size:`sm`,className:`menu-item-check`}),t&&(0,S.jsx)(`span`,{className:`kbd`,children:t})]})}function Ua(){return(0,S.jsx)(`hr`,{className:`menu-sep`})}function Wa({children:e}){return(0,S.jsx)(`div`,{className:`menu-label`,children:e})}function Ga({changeset:e}){let{spec:t,repo:n,pr:r}=e;if(r)return null;let i=t.kind===`working-tree`,a=i?`working tree`:n.branch||`HEAD`,o=i?`HEAD`:t.base,s=[i?`comparing your working tree against HEAD${n.branch?` on branch ${n.branch}`:``}`:`comparing ${a} against ${o}`,n.worktree&&`linked worktree '${n.worktree}'`].filter(Boolean).join(` · `);return(0,S.jsxs)(`span`,{className:`cmp`,title:s,children:[(0,S.jsx)(`span`,{className:`repo`,children:n.name}),(0,S.jsx)(`span`,{className:`cmp-dot`,"aria-hidden":`true`,children:`·`}),(0,S.jsx)(`span`,{className:`cmp-side`,children:a}),(0,S.jsx)(U,{name:`arrow`,size:`sm`,className:`cmp-arrow`}),(0,S.jsx)(`span`,{className:`cmp-side cmp-side-base`,children:o})]})}var Ka={success:`CI passing`,failure:`CI failing`,pending:`CI running`,none:`no checks`,unknown:`checks not visible to your token`};function qa(e){return e.state===`open`?e.changesRequested>0?{label:`changes requested`,className:`chip-attn`}:e.checks.state===`failure`?{label:`CI failing`,className:`pr-check-failure`}:e.draft?{label:`draft`,className:`chip-mute pr-state pr-state-draft`}:e.checks.state===`pending`?{label:`CI running`,className:`pr-check-pending`}:null:{label:e.state,className:`chip-mute pr-state pr-state-${e.state}`}}function Ja({user:e,large:t=!1}){let n=t?`pr-avatar pr-avatar-lg`:`pr-avatar`;return e.avatarUrl?(0,S.jsx)(`img`,{className:n,src:e.avatarUrl,alt:``}):(0,S.jsx)(`span`,{className:`${n} pr-avatar-none`,children:(0,S.jsx)(U,{name:`user`,size:t?`md`:`sm`})})}var Ya=e=>{let t=va(e);return/^\d/.test(t)?`${t} ago`:t};function Xa({pr:e}){let[t,n]=(0,x.useState)(!1),r=e.commits.at(-1),i=[Ka[e.checks.state],r?`pushed ${Ya(r.at)}`:``].filter(Boolean).join(` · `),a=e.approvals===0&&e.changesRequested===0?{text:`no reviews yet`,tone:`mute`}:e.changesRequested>0?{text:`changes requested${e.approvals>0?` · ${e.approvals} ${e.approvals===1?`approval`:`approvals`}`:``}`,tone:`attn`}:{text:`${e.approvals} ${e.approvals===1?`approval`:`approvals`}`,tone:`ok`},o=e.commits.length,s=t=>`https://${e.host}/${e.owner}/${e.repo}/pull/${e.number}/commits/${t}`;return(0,S.jsxs)(`section`,{className:`menu-panel menu-panel-left pr-card`,"aria-label":`pull request details`,children:[(0,S.jsxs)(`div`,{className:`pr-card-who`,children:[(0,S.jsx)(Ja,{user:e.author,large:!0}),(0,S.jsxs)(`span`,{className:`pr-card-who-text`,children:[(0,S.jsx)(`span`,{className:`pr-card-login`,children:e.author.login}),(0,S.jsxs)(`span`,{className:`pr-card-where`,children:[e.owner,`/`,e.repo,` #`,e.number]})]})]}),(0,S.jsxs)(`div`,{className:`pr-card-body`,children:[(0,S.jsxs)(`div`,{className:`pr-card-refs`,title:`${e.head.ref} into ${e.base.ref}`,children:[(0,S.jsx)(`code`,{className:`pr-ref`,children:e.head.ref}),(0,S.jsx)(U,{name:`arrow`,size:`sm`,className:`cmp-arrow`}),(0,S.jsx)(`code`,{className:`pr-ref pr-ref-base`,children:e.base.ref})]}),(0,S.jsxs)(`ul`,{className:`pr-card-facts`,children:[(0,S.jsxs)(`li`,{className:`pr-fact pr-fact-${e.checks.state}`,children:[(0,S.jsx)(`i`,{className:`pr-fact-dot`,"aria-hidden":`true`}),e.checks.url?(0,S.jsx)(`a`,{href:e.checks.url,target:`_blank`,rel:`noreferrer`,children:i}):i]}),(0,S.jsxs)(`li`,{className:`pr-fact pr-fact-${a.tone}`,children:[(0,S.jsx)(U,{name:a.tone===`ok`?`check`:a.tone===`attn`?`alert`:`chat`,size:`sm`}),a.text]})]}),o>0&&(0,S.jsxs)(`div`,{className:`pr-commits`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`pr-commits-toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[(0,S.jsx)(`span`,{className:`chevron${t?``:` chevron-shut`}`,children:(0,S.jsx)(U,{name:`chev`,size:`sm`})}),o,` `,o===1?`commit`:`commits`]}),t&&(0,S.jsx)(`ol`,{className:`pr-commit-list`,children:[...e.commits].reverse().map(e=>(0,S.jsx)(`li`,{children:(0,S.jsxs)(`a`,{className:`pr-commit`,href:s(e.sha),target:`_blank`,rel:`noreferrer`,title:`${e.subject}${e.author?`, by ${e.author.login}`:``}, opens on GitHub`,children:[(0,S.jsx)(`code`,{className:`pr-commit-sha`,children:e.sha.slice(0,7)}),(0,S.jsx)(`span`,{className:`pr-commit-subject`,children:e.subject}),(0,S.jsx)(`span`,{className:`pr-commit-ago`,children:va(e.at)})]})},e.sha))})]})]}),(0,S.jsxs)(`a`,{className:`btn btn-ghost pr-card-link`,href:e.url,target:`_blank`,rel:`noreferrer`,children:[`Open on GitHub`,(0,S.jsx)(U,{name:`link`,size:`sm`})]})]})}function Za({pr:e}){let[t,n]=(0,x.useState)(!1),r=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(!t)return;let e=e=>{r.current?.contains(e.target)||n(!1)},i=e=>{e.key===`Escape`&&(e.stopPropagation(),n(!1))};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,i,!0),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,i,!0)}},[t]);let i=qa(e);return(0,S.jsxs)(`span`,{className:`where pr-chips menu`,ref:r,children:[(0,S.jsxs)(`button`,{type:`button`,className:`pr-title`,"aria-haspopup":`dialog`,"aria-expanded":t,onClick:()=>n(e=>!e),title:t?void 0:`${e.owner}/${e.repo}#${e.number}: author, branches, checks, reviews`,children:[(0,S.jsx)(U,{name:`pr`,size:`sm`}),(0,S.jsxs)(`span`,{className:`pr-number`,children:[`#`,e.number]}),(0,S.jsx)(`span`,{className:`pr-title-text`,children:e.title})]}),i&&(0,S.jsx)(`span`,{className:`chip ${i.className}`,children:i.label}),t&&(0,S.jsx)(Xa,{pr:e})]})}var Qa={waiting:`no agent is attached; sends queue for the next poll, and the prompt is copied so you can paste it yourself`,listening:`your agent is here and listening; anything you send reaches it right away`,working:`the agent received feedback and is working on it`},$a=`the agent is attached but its last poll ended; a send queues and reaches it when it polls again`,eo=`your agent opened this review and is reading the change before it starts listening — its guide lands first; a send queues and reaches it at its first poll`,to=/^(working on|answered|picked up|outlining) (.+)$/,no=e=>e.charAt(0).toUpperCase()+e.slice(1);function ro(e,t,n,r){if(e===`waiting`)return r?{verb:`Invite`,detail:`your agent`}:{verb:`No agent`};if(e===`listening`)return{verb:`Listening`};if(n){let e=to.exec(n);return e?{verb:no(e[1]),detail:e[2]}:{verb:no(n)}}return t===`arriving`?{verb:`Reading`,detail:`the change`}:t===`repolling`?{verb:`Paused`,detail:`sends wait`}:{verb:`Working`}}function io(e,t,n){return n?`happy`:e===`waiting`?`shut`:e===`listening`||t===`arriving`||t===`repolling`?`open`:`plus`}function ao(e,t){return e===`working`?t===`repolling`?$a:t===`arriving`?eo:Qa[e]:Qa[e]}function oo(e){let t=Math.max(0,Math.round(e/1e3));return t<60?`${t}s`:`${Math.round(t/60)}m`}function so({presence:e,reason:t,since:n,activity:r,onInvite:i,batch:a,monitorOpen:o=!1,onOpenMonitor:s,monitorPanel:c,suggestion:l,seat:u,faceAway:d=!1,onHover:f}){let[,p]=(0,x.useState)(0),m=(0,x.useRef)(null),h=e===`working`&&typeof n==`number`;(0,x.useEffect)(()=>{if(!h)return;let e=setInterval(()=>p(e=>e+1),1e4);return()=>clearInterval(e)},[h]),(0,x.useEffect)(()=>{if(!o||!s)return;let e=e=>{m.current?.contains(e.target)||s(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[o,s]);let[g,_]=(0,x.useState)(!1),v=(0,x.useRef)(t);(0,x.useEffect)(()=>{let e=v.current;if(v.current=t,t!==`replied`||e===`replied`)return;_(!0);let n=setTimeout(()=>_(!1),1500);return()=>{clearTimeout(n),_(!1)}},[t]);let y=a?.segments.length??0,b=e!==`waiting`&&!!l&&y===0,C=b?{verb:`Suggests`,detail:`layers`}:ro(e,t,r,e===`waiting`&&!!i),w=e===`waiting`?void 0:f,T=(0,S.jsx)(`span`,{className:`presence-face${d?` presence-face-away`:``}${g?` presence-face-cheer`:``}`,ref:u,"aria-hidden":`true`,children:(0,S.jsx)(za,{eyes:b?`happy`:io(e,t,g)})}),E=(0,S.jsxs)(S.Fragment,{children:[T,(0,S.jsxs)(`span`,{className:`presence-label`,children:[(0,S.jsx)(`span`,{className:`presence-verb`,children:C.verb}),C.detail&&(0,S.jsxs)(S.Fragment,{children:[` `,(0,S.jsx)(`span`,{className:`presence-detail`,children:C.detail})]}),h&&(0,S.jsxs)(`span`,{className:`presence-ago`,children:[` · `,oo(Date.now()-n)]})]})]});if(e===`waiting`&&i)return(0,S.jsx)(`button`,{type:`button`,className:`presence presence-waiting presence-invite`,onClick:i,title:`bring your agent into this review`,children:E});if(b)return(0,S.jsxs)(`button`,{type:`button`,className:`presence presence-${e} presence-suggests`,onClick:l.onOutline,onPointerEnter:w,title:l.reason?`the agent suggests reading this in layers: “${l.reason}”`:`the agent suggests reading this in layers`,children:[E,(0,S.jsx)(`span`,{className:`presence-cta`,children:`Ask it`})]});if(e===`waiting`||y===0||!s)return(0,S.jsx)(`span`,{className:`presence presence-${e}`,title:ao(e,t),onPointerEnter:w,children:E});let D=Math.round(a.done/y*100);return(0,S.jsxs)(`div`,{className:`menu monitor-anchor`,ref:m,children:[(0,S.jsxs)(`button`,{type:`button`,className:`presence presence-${e} presence-batch`,"aria-haspopup":`dialog`,"aria-expanded":o,onClick:()=>s(!o),onPointerEnter:w,title:`${Qa[e]}. ${a.done} of ${y} answered; click to watch the queue`,children:[D>0&&(0,S.jsx)(`span`,{className:`presence-fill`,style:{width:`${D}%`},"aria-hidden":`true`}),E,` `,(0,S.jsxs)(`span`,{className:`presence-batch-n`,children:[a.done,`/`,y]})]}),o&&c]})}function co({changeset:e,agent:t={},review:n={},settings:r={}}){let{openComments:i=0,publicDrafts:a=0,onFinishReview:o}=n,s=(0,x.useRef)(null),[c,l]=(0,x.useState)(!1),[u,d]=(0,x.useState)(0),{theme:f,onSetTheme:p,critter:m=!0,onSetCritter:h,onShowShortcuts:g,onShowPrivacy:_}=r;return(0,S.jsxs)(`header`,{className:`top`,children:[(0,S.jsxs)(`span`,{className:`mark`,children:[(0,S.jsx)(Ba,{size:36}),(0,S.jsx)(`span`,{className:`wordmark`,role:`img`,"aria-label":`Diffo`,children:[...`Diffo`].map((e,t)=>(0,S.jsx)(`span`,{className:`wordmark-letter`,style:{"--i":t},"aria-hidden":`true`,children:e},t))}),Rt()&&(0,S.jsx)(`span`,{className:`dev-badge`,title:`this review is served by a diffo running from a source checkout, not the released CLI`,children:`dev`})]}),e.pr&&(0,S.jsx)(Za,{pr:e.pr}),(0,S.jsx)(Ga,{changeset:e}),t.presence&&m?(0,S.jsx)(La,{presence:t.presence,reason:t.reason,seat:s,onAway:l,summon:u}):(0,S.jsx)(`span`,{className:`grow`}),t.presence&&(0,S.jsx)(so,{presence:t.presence,reason:t.reason,since:t.since,activity:t.activity,onInvite:t.onInvite,batch:t.batch,monitorOpen:t.monitorOpen,onOpenMonitor:t.onOpenMonitor,monitorPanel:t.monitorPanel,suggestion:t.suggestion,seat:s,faceAway:m&&c,onHover:m?()=>d(e=>e+1):void 0}),o&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:o,title:e.pr?a>0?`submit your review on GitHub with ${a} pending ${a===1?`comment`:`comments`}; private threads go to your agent`:`submit your review on GitHub; private threads and coverage go to your agent`:`finish review: send open comments + coverage to your agent`,children:e.pr?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(U,{name:`globe`,size:`sm`}),` Submit review`,a>0?` (${a})`:``]}):`Finish review${i>0?` (${i})`:``}`}),(0,S.jsx)(Va,{label:`Settings`,triggerClassName:`btn btn-ghost btn-icon`,children:e=>(0,S.jsxs)(S.Fragment,{children:[p&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(Wa,{children:`Theme`}),(0,S.jsx)(Ha,{icon:`display`,checked:f===`system`,onClick:()=>{e(),p(`system`)},children:`System`}),(0,S.jsx)(Ha,{icon:`sun`,checked:f===`light`,onClick:()=>{e(),p(`light`)},children:`Light`}),(0,S.jsx)(Ha,{icon:`moon`,checked:f===`dark`,onClick:()=>{e(),p(`dark`)},children:`Dark`})]}),h&&(0,S.jsxs)(S.Fragment,{children:[p&&(0,S.jsx)(Ua,{}),(0,S.jsx)(Ha,{icon:`sparkle`,checked:m,onClick:()=>{e(),h(!m)},children:`Companion`})]}),g&&(0,S.jsxs)(S.Fragment,{children:[(p||h)&&(0,S.jsx)(Ua,{}),(0,S.jsx)(Ha,{icon:`keys`,kbd:`?`,onClick:()=>{e(),g()},children:`Shortcuts`})]}),_&&(0,S.jsxs)(S.Fragment,{children:[(p||h||g)&&(0,S.jsx)(Ua,{}),(0,S.jsx)(Ha,{icon:`lock`,onClick:()=>{e(),_()},children:`Privacy`})]})]})})]})}function lo({presence:e,reason:t,onClose:n}){let{data:r,isLoading:i,error:a}=bt(!0),[o,s]=(0,x.useState)(!1),[c,l]=(0,x.useState)(!1),[u,d]=(0,x.useState)(!1),f=e!==`waiting`,[p,m]=(0,x.useState)(f?`connected`:`invite`),[h,g]=(0,x.useState)(!1),_=(0,x.useRef)(f);(0,x.useEffect)(()=>{f!==_.current&&(_.current=f,m(f?`connected`:`invite`),g(!f))},[f]);let v=(0,x.useRef)(n);v.current=n,(0,x.useEffect)(()=>{if(p!==`connected`)return;let e=setTimeout(()=>v.current(),1800);return()=>clearTimeout(e)},[p]);let y=e=>{Ct(e).then(e=>{l(!e),e&&(s(!0),d(!0),setTimeout(()=>s(!1),2500))})};return p===`connected`?(0,S.jsx)(At,{title:`Agent attached`,onClose:n,children:(0,S.jsxs)(`div`,{className:`invite-connected`,children:[(0,S.jsx)(`span`,{className:`presence-dot`}),(0,S.jsx)(`p`,{className:`cov-note`,children:`Everything you send from here lands in that thread.`})]})}):(0,S.jsxs)(At,{title:`Connect your agent`,onClose:n,children:[h&&(0,S.jsxs)(`div`,{className:`warn`,children:[(0,S.jsx)(U,{name:`alert`,size:`sm`}),(0,S.jsx)(`div`,{children:t===`ended`?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`b`,{children:`Your agent left the review`}),`: it detached on purpose. Bring it back whenever you like.`]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`b`,{children:`Your agent disconnected`}),`: its poll died without detaching.`]})})]}),i&&(0,S.jsx)(`div`,{className:`shimmer`}),a&&(0,S.jsxs)(`p`,{className:`cov-note`,children:[`Couldn't build the invite: `,a.message]}),r&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`p`,{className:`cov-note`,children:`Paste this to your agent. Its Diffo skill does the rest.`}),(0,S.jsxs)(`button`,{type:`button`,className:`invite-cmd`,title:o?`Copied`:`copy the ask`,onClick:()=>y(r.ask),children:[(0,S.jsx)(`code`,{children:r.ask}),(0,S.jsx)(U,{name:o?`check`:`copy`,size:`sm`})]}),u&&(0,S.jsxs)(`div`,{className:`invite-live`,children:[(0,S.jsx)(`span`,{className:`presence-dot`}),`Listening for your agent…`]}),c&&(0,S.jsxs)(`div`,{className:`warn`,children:[(0,S.jsx)(U,{name:`alert`,size:`sm`}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`b`,{children:`Couldn't reach the clipboard`}),`: this browser blocked it. Select the text and copy it by hand.`]})]})]})]})}function uo(e){return e.hunks.length>0?e.hunks.map(e=>e.id):[fo(e)]}function fo(e){return`file:${e.status}:${e.oldPath??``}${e.path}`}function po(e,t){return t!==void 0&&uo(e).every(e=>t.has(e))}var mo=`Since your review`;function ho(e,t){return e.hunks.find(e=>e.lines.some(e=>e.kind!==`del`&&e.newNo===t))}function go(e,t){let n=t.get(e.path);if(!n)return{at:e};let r=e.line===void 0?void 0:ho(n,e.line);return r?{at:e,file:n,hunkId:r.id}:{at:e,file:n}}function _o(e,t){if(e&&e.length!==0)return e.map(e=>({decision:e,places:(e.at??[]).map(e=>go(e,t))}))}function vo(e,t){if(!e||e.items.length===0)return[];let n=new Map(t.map(e=>[e.path,e])),r=new Set,i=e.items.map((e,t)=>{let i=new Set,a=[],o=[];for(let t of e.files){let e=ut(t);if(i.has(e))continue;i.add(e),r.add(e);let s=n.get(e);if(!s){o.push(e);continue}let c=dt(t);a.push(c?{file:s,note:c}:{file:s})}let s=_o(e.decisions,n);return{id:e.id,number:t+1,title:e.title,...e.summary?{summary:e.summary}:{},...e.kind?{kind:e.kind}:{},files:a,missing:o,derived:!1,...s?{decisions:s}:{}}}),a=t.filter(e=>!r.has(e.path));return a.length>0&&i.push({id:null,number:null,title:mo,files:a.map(e=>({file:e})),missing:[],derived:!0}),i}function yo(e,t){return e.map(e=>{let n=e.files.filter(e=>!t(e.file)),r=e.files.length-n.length;return r===0?e:{...e,files:n,hidden:r}})}function bo(e){return e.id??`since`}function xo(e){return e.filter(e=>e.anchor.kind===`changeset`&&st(e)).at(-1)}function So(e){return e.find(e=>e.github?.kind===`description`)}function Co(e){let t=new Map;for(let n of e)for(let{file:e}of n.files)t.has(e.path)||t.set(e.path,n);return t}function wo(e,t){let n=0,r=0,i=0;for(let{file:a}of e.files){let e=uo(a),o=e.filter(e=>t.has(e)).length;n+=e.length,r+=o,o===e.length&&i++}return{files:e.files.length,doneFiles:i,marks:n,doneMarks:r}}function To(e){let t=0,n=0;for(let{file:r}of e.files)for(let e of r.hunks)for(let r of e.lines)r.kind===`add`?t++:r.kind===`del`&&n++;return{additions:t,deletions:n}}function Eo(e,t){let n=wo(e,t);return n.doneFiles===n.files}function Do(e,t,n,r=()=>!1){for(let i=t+n;i>=0&&i<e.length;i+=n)if(!r(e[i]))return i;return null}function Oo(e,t){let n=e.findIndex(e=>e.files.length>0&&!Eo(e,t));return n===-1?0:n}var ko=`#diffo-file:`;function Ao(e,t){return`${ko}${encodeURIComponent(e)}${t===null?``:`:${t}`}`}function jo(e){if(!e.startsWith(`#diffo-file:`))return null;let t=e.slice(12),n=/^(.*):(\d+)$/.exec(t);try{return n?{path:decodeURIComponent(n[1]),line:Number.parseInt(n[2],10)}:{path:decodeURIComponent(t),line:null}}catch{return null}}var Mo=/`([^`\n]+)`/g,No=/^([^\s:`]+?)(?::(\d+)(?:-\d+)?)?$/;function Po(e){let t=e.closest(`a[href], [data-diffo-jump]`);return t?jo(t.getAttribute(`data-diffo-jump`)??t.getAttribute(`href`)??``):null}function Y(e,t){if(t.includes(e))return e;let n=t.filter(t=>t.slice(t.lastIndexOf(`/`)+1)===e);return n.length===1?n[0]:null}function Fo(e,t){return t.length===0?e:e.split(/(```[\s\S]*?```|\[[^\]\n]*\]\([^)\n]*\))/).map((e,n)=>n%2==1?e:e.replace(Mo,(e,n)=>{let r=No.exec(n);if(!r)return e;let i=Y(r[1],t);return i===null?e:`[${e}](${Ao(i,r[2]===void 0?null:Number.parseInt(r[2],10))})`})).join(``)}function Io({state:e=!1}){return(0,S.jsx)(`span`,{className:`markbox`,"data-state":e===`mixed`?`mixed`:e?`on`:`off`,"aria-hidden":`true`,children:e===!0&&(0,S.jsx)(U,{name:`check`,size:`sm`})})}var Lo=()=>{let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`?!0:e===`light`?!1:window.matchMedia?.(`(prefers-color-scheme: dark)`).matches??!1};function Ro(){let[e,t]=(0,x.useState)(()=>typeof window<`u`&&Lo());return(0,x.useEffect)(()=>{let e=()=>t(Lo()),n=window.matchMedia?.(`(prefers-color-scheme: dark)`);n?.addEventListener(`change`,e);let r=new MutationObserver(e);return r.observe(document.documentElement,{attributeFilter:[`data-theme`]}),()=>{n?.removeEventListener(`change`,e),r.disconnect()}},[]),e}function zo(e){return`file-${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}`}function Bo(e,t,n=`start`){let r=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1,i=e.closest(`.reading-pane`),a=i?.scrollTop,o=()=>e.scrollIntoView({behavior:r?`instant`:`smooth`,block:n});if(o(),r){t?.(e);return}let s=i?.querySelector(`.reading-col`),c=e.offsetTop,l=null;s&&typeof ResizeObserver==`function`&&(l=new ResizeObserver(()=>{let t=e.offsetTop;t!==c&&(c=t,o())}),l.observe(s));let u=!1,d=()=>{u||(u=!0,l?.disconnect(),i&&i.scrollTop===a&&e.scrollIntoView({behavior:`instant`,block:n}),t?.(e))};i?.addEventListener(`scrollend`,d,{once:!0}),setTimeout(d,1200)}var Vo=[/[._-](test|spec)s?\.[^/]+$/,/(^|\/)test_[^/]+$/,/(^|[/.a-z0-9])Tests?\.[^/]+$/,/(^|\/)test[-_]?([Uu]tils?|[Hh]elpers?|[Ss]etup|[Ss]upport)\.[^/]+$/,/\.cy\.[^/]+$/,/[._-]e2e\.[^/]+$/,/(^|\/)(jest|vitest|playwright|cypress|karma|wdio|protractor)[.-](config|setup)(\.[^/]+)?$/,/\.snap$/,/[a-z0-9]Specs?\.(kt|kts|scala|groovy|swift)$/,/[a-z0-9](IT|ITCase)\.(java|kt|groovy|scala)$/,/(^|\/)(conftest|tests?)\.py$/,/(^|\/)pytest\.ini$/,/(^|\/)(spec|rails)_helper\.rb$/,/(^|\/)spec\/.+\.rb$/,/(^|\/)phpunit\.xml(\.dist)?$/,/(^|\/)mock_[^/]+\.go$/,/_mock\.go$/,/\.golden$/,/\.(feature|robot)$/,/(^|\/)(__tests__|__mocks__|__snapshots__|__fixtures__|[Tt]ests?)\//,/\.([A-Z][A-Za-z]*)?Tests?\//,/(^|\/)[a-z]+Tests?\//,/(^|\/)test[A-Z][A-Za-z]*\//,/(^|\/)tests?[-_][a-z]+\//,/(^|[/_-])e2e([-_][^/]*)?\//,/(^|\/)(cypress|playwright|testdata|step_definitions|mocks)\//];function Ho(e){return Vo.some(t=>t.test(e))}var Uo=`diffo:ui:hideReviewed`,Wo=`diffo:ui:hideTests`;function Go(e){let t=localStorage.getItem(e);return t===`1`||t!==`0`&&null}function Ko(e,t){let n=0,r=0,i=0,a=0,o=[];for(let s of e){let e=t.isDone(s);if(!t.pinned.has(s.path)){if(t.onlyChanged&&!t.changed.has(s.path)){e||(a++,o.push(s.path));continue}if(t.hideTests&&Ho(s.path)){e||(i++,o.push(s.path));continue}}r++,e||n++}return{left:n,total:r,excludedTests:i,excludedUnchanged:a,excludedPaths:o}}function qo(e,t){let n=[],r=t.query.trim().toLowerCase(),i=0,a=0,o=0,s=0;for(let c of e){if(t.pinned.has(c.path)){n.push(c);continue}if(r!==``&&!c.path.toLowerCase().includes(r)){s++;continue}if(t.onlyChanged&&!t.changed.has(c.path)){o++;continue}if(t.hideTests&&Ho(c.path)){i++;continue}if(t.hideReviewed&&t.isDone(c)){a++;continue}n.push(c)}return{visible:n,hiddenTests:i,hiddenReviewed:a,hiddenUnchanged:o,hiddenQuery:s}}function Jo(e,t,n){let[r,i]=(0,x.useState)(()=>Go(Uo)),[a,o]=(0,x.useState)(()=>Go(Wo)),[s,c]=(0,x.useState)(new Set),[l,u]=(0,x.useState)(``),d=(0,x.useCallback)(e=>{u(e),c(e=>e.size===0?e:new Set)},[]),f=r??e.length>25,p=a??!1,m=(0,x.useCallback)(e=>{localStorage.setItem(Uo,e?`1`:`0`),i(e),c(new Set)},[]),h=(0,x.useCallback)(e=>{localStorage.setItem(Wo,e?`1`:`0`),o(e)},[]),g=(0,x.useCallback)(e=>{c(t=>t.has(e)?t:new Set(t).add(e))},[]),_=(0,x.useCallback)(e=>{c(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),v=n.set,y=(0,x.useCallback)(()=>{localStorage.setItem(Uo,`0`),localStorage.setItem(Wo,`0`),i(!1),o(!1),c(new Set),u(``),v(!1)},[v]),b=(0,x.useMemo)(()=>qo(e,{query:l,hideReviewed:f,hideTests:p,onlyChanged:n.on,changed:n.changed,pinned:s,isDone:t}),[e,l,f,p,n.on,n.changed,s,t]),S=(0,x.useMemo)(()=>e.filter(e=>Ho(e.path)).length,[e]),C=(0,x.useMemo)(()=>Ko(e,{hideTests:p,onlyChanged:n.on,changed:n.changed,pinned:s,isDone:t}),[e,p,n.on,n.changed,s,t]);return{query:l,setQuery:d,hideReviewed:f,hideTests:p,setHideReviewed:m,setHideTests:h,onlyChanged:n.on,setOnlyChanged:v,files:b.visible,hiddenTests:b.hiddenTests,hiddenReviewed:b.hiddenReviewed,hiddenUnchanged:b.hiddenUnchanged,hiddenQuery:b.hiddenQuery,testCount:S,changedCount:n.changed.size,scope:C,pinned:s,pin:g,unpin:_,showAll:y}}var Yo=e=>e.slice(e.lastIndexOf(`/`)+1),Xo={added:`new file`,deleted:`deleted`,renamed:`renamed`,modified:`edited`};function Zo(e){let t={dirs:new Map,files:[],path:``};for(let n of e){let e=n.path.split(`/`),r=t;for(let t of e.slice(0,-1)){let e=r.dirs.get(t);e||(e={dirs:new Map,files:[],path:r.path===``?t:`${r.path}/${t}`},r.dirs.set(t,e)),r=e}r.files.push(n)}let n=e=>{let t=[];for(let[r,i]of e.dirs){let e={kind:`dir`,name:r,path:i.path,children:n(i)};for(;;){let t=e.children.length===1?e.children[0]:void 0;if(t===void 0||t.kind!==`dir`)break;e={kind:`dir`,name:`${e.name}/${t.name}`,path:t.path,children:t.children}}t.push(e)}t.sort((e,t)=>e.name.localeCompare(t.name));let r=e.files.map(e=>({kind:`file`,file:e})).sort((e,t)=>Yo(e.file.path).localeCompare(Yo(t.file.path)));return[...t,...r]};return n(t)}function Qo(e){return e.kind===`file`?[e.file]:e.children.flatMap(Qo)}function $o(e){return Zo(e).flatMap(Qo)}function es({file:e,depth:t,done:n,current:r,threads:i,wantsYou:a=0,changed:o=!1,note:s,onPick:c,onToggleViewed:l,onAsk:u}){let d=i?.length??0,f=0,p=0;for(let t of e.hunks)for(let e of t.lines)e.kind===`add`?f++:e.kind===`del`&&p++;let m=f>0||p>0?` · ${f>0?`+${f}`:``}${f>0&&p>0?` `:``}${p>0?`−${p}`:``}`:``;return(0,S.jsxs)(`div`,{className:`row${n?` row-done`:``}`,"aria-current":r?`true`:void 0,"data-path":e.path,style:{paddingLeft:12+t*14},children:[(0,S.jsx)(`button`,{type:`button`,className:`row-box`,role:`checkbox`,"aria-checked":n,"aria-label":`${n?`Mark not reviewed`:`Mark reviewed`}: ${e.path}`,"data-tip":n?`Mark not reviewed`:`Mark reviewed`,disabled:!l,onClick:l,children:(0,S.jsx)(Io,{state:n})}),(0,S.jsx)(`button`,{type:`button`,className:`row-pick`,title:`${e.path} · ${Xo[e.status]}${n?` · read`:``}${m}${s?`, ${s}`:``}`,onClick:()=>{if(c)return c();let t=document.getElementById(zo(e.path));t&&Bo(t)},children:(0,S.jsxs)(`span`,{className:`row-name`,children:[e.status===`added`&&(0,S.jsx)(`span`,{className:`row-st row-st-add`,"aria-hidden":`true`,children:`+`}),e.status===`deleted`&&(0,S.jsx)(`span`,{className:`row-st row-st-del`,"aria-hidden":`true`,children:`−`}),e.status===`renamed`&&e.oldPath!==null&&(0,S.jsxs)(`span`,{className:`row-was`,children:[Yo(e.oldPath),` →`]}),(0,S.jsx)(`span`,{className:`row-base${e.status===`deleted`?` row-base-del`:``}`,children:Yo(e.path)})]})}),(0,S.jsxs)(`span`,{className:`row-right`,children:[o&&(0,S.jsx)(`span`,{role:`img`,className:`row-since row-since-changed`,title:`your agent rewrote this since you last finished a review`,"aria-label":`changed since your last review`}),(0,S.jsx)(`span`,{className:`row-passive`,children:a>0?(0,S.jsxs)(`span`,{className:`row-count row-count-hot`,title:`${a} of ${d} thread${d===1?``:`s`} needs you`,children:[(0,S.jsx)(U,{name:`chat`,size:`sm`}),a,` needs you`]}):d>0?(0,S.jsxs)(`span`,{className:`row-count`,title:`${d} thread${d===1?``:`s`}`,children:[(0,S.jsx)(U,{name:`chat`,size:`sm`}),d]}):null}),(0,S.jsx)(`span`,{className:`row-acts`,children:u&&(0,S.jsx)(`button`,{type:`button`,className:`row-act`,"data-tip":`Comment on this file`,"aria-label":`Comment on this file`,onClick:u,children:(0,S.jsx)(U,{name:`chat`,size:`sm`})})})]})]})}function ts({files:e,viewed:t,selectedPath:n,onPickFile:r,onToggleFileViewed:i,onMarkFiles:a,onClearFiles:o,onAskFile:s,threads:c,attention:l,changed:u,notes:d,forceOpen:f=!1}){let[p,m]=(0,x.useState)(new Set),h=(0,x.useCallback)(e=>po(e,t),[t]),g=(0,x.useMemo)(()=>Zo(e),[e]),_=(e,t)=>(0,S.jsx)(es,{file:e,depth:t,done:h(e),current:n===e.path,threads:c?.get(e.path),wantsYou:(l?.get(e.path)??[]).filter(e=>e.turn===`yours`).length,changed:u?.has(e.path)??!1,note:d?.get(e.path),onPick:r?()=>r(e.path):void 0,onToggleViewed:i?()=>i(e.path):void 0,onAsk:s?()=>s(e.path):void 0},e.path),v=(e,t)=>{let n=Qo(e),r=f||!p.has(e.path),i=n.filter(h).length,s=n.length>0&&i===n.length,c=n.filter(e=>!h(e)),l=(0,S.jsxs)(`div`,{className:`row row-dir${s?` row-done`:``}`,style:{paddingLeft:12+t*14},children:[(0,S.jsx)(`button`,{type:`button`,className:`row-box`,role:`checkbox`,"aria-checked":s?!0:i>0&&`mixed`,"aria-label":s?`Mark ${e.name} not reviewed`:`Mark ${c.length} file${c.length===1?``:`s`} in ${e.name} reviewed`,"data-tip":s?`Mark ${n.length} file${n.length===1?``:`s`} not reviewed`:`Mark ${c.length} file${c.length===1?``:`s`} reviewed`,disabled:s?!o:!a,onClick:()=>{s?o?.(n.map(e=>e.path)):a?.(c.map(e=>e.path))},children:(0,S.jsx)(Io,{state:s?!0:i>0&&`mixed`})}),(0,S.jsx)(`button`,{type:`button`,className:`row-pick`,title:e.path,"aria-expanded":r,onClick:()=>m(t=>{let n=new Set(t);return r?n.add(e.path):n.delete(e.path),n}),children:(0,S.jsxs)(`span`,{className:`row-name`,children:[(0,S.jsx)(`span`,{className:`chevron${r?``:` chevron-shut`}`,children:(0,S.jsx)(U,{name:`chev`,size:`sm`})}),(0,S.jsx)(`span`,{className:`dir-ico`,children:(0,S.jsx)(U,{name:`folder`,size:`sm`})}),(0,S.jsx)(`span`,{className:`row-base`,children:e.name})]})})]},`dir:${e.path}`);return r?[l,...y(e.children,t+1)]:[l]},y=(e,t)=>e.flatMap(e=>e.kind===`file`?[_(e.file,t)]:v(e,t));return(0,S.jsx)(S.Fragment,{children:y(g,0)})}function ns({files:e,viewed:t,selectedPath:n,onPickFile:r,onToggleFileViewed:i,onMarkFiles:a,onClearFiles:o,onAskFile:s,threads:c,attention:l,changed:u,query:d,onQuery:f,focusTick:p=0,hideReviewed:m=!1,onHideReviewed:h,hideTests:g=!1,onHideTests:_,onlyChanged:v=!1,onOnlyChanged:y}){let[b,C]=(0,x.useState)(``),w=d??b,T=f??C,E=(0,x.useRef)(null);(0,x.useEffect)(()=>{p>0&&E.current?.focus()},[p]);let D=(0,x.useCallback)(e=>po(e,t),[t]),O=(0,x.useMemo)(()=>{let t=w.trim().toLowerCase();return e.filter(e=>(t===``||e.path.toLowerCase().includes(t))&&!(m&&D(e))&&!(g&&Ho(e.path))&&!(v&&!(u?.has(e.path)??!1)))},[e,w,m,g,v,u,D]),k=w.trim()!==``,A=w.trim().toLowerCase(),j=e.filter(e=>A===``||e.path.toLowerCase().includes(A)).length-O.length,M=!!(h||_||y);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`rail-search`,children:(0,S.jsxs)(`span`,{className:`sb`,children:[(0,S.jsx)(U,{name:`search`,size:`sm`}),(0,S.jsx)(`input`,{ref:E,className:`nav-search`,type:`search`,placeholder:`Filter files`,"aria-label":`Filter files`,title:`Press / to jump here`,value:w,onChange:e=>T(e.target.value)}),w!==``&&(0,S.jsx)(`button`,{type:`button`,className:`sb-clear`,"data-tip":`Clear filter`,"aria-label":`Clear filter`,onClick:()=>{T(``),E.current?.focus()},children:(0,S.jsx)(U,{name:`x`,size:`sm`})})]})}),(0,S.jsxs)(`div`,{className:`rail-scroll`,children:[(0,S.jsx)(ts,{files:O,viewed:t,selectedPath:n,onPickFile:r,onToggleFileViewed:i,onMarkFiles:a,onClearFiles:o,onAskFile:s,threads:c,attention:l,changed:u,forceOpen:k}),O.length===0&&j===0&&(0,S.jsx)(`div`,{className:`rail-empty`,children:`no files match`})]}),j>0&&(0,S.jsxs)(`div`,{className:`rail-hidden`,children:[j,` `,j===1?`file`:`files`,` hidden by filters`,M&&(0,S.jsx)(`button`,{type:`button`,className:`rail-hidden-show`,onClick:()=>{m&&h?.(!1),g&&_?.(!1),v&&y?.(!1)},children:`show`})]})]})}var rs=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function is(e){if(e.files.length>0)return null;let t=e.hidden??0;return t>0?`${rs(t,`test`)} hidden`:e.missing.length===0?`nothing here now`:`${rs(e.missing.length,`listed file`)} not in the changeset`}function as({layer:e,viewed:t}){let n=is(e);if(n!==null)return(0,S.jsx)(`span`,{children:n});let r=e.hidden??0,i=wo(e,t),{additions:a,deletions:o}=To(e),s=i.doneFiles===i.files?` · read`:``,c=e.kind===`mechanical`?` · mechanical`:``,l=r>0?` · ${r} hidden`:``;return(0,S.jsxs)(`span`,{children:[rs(i.files,`file`),(a>0||o>0)&&(0,S.jsxs)(S.Fragment,{children:[` · `,a>0&&(0,S.jsxs)(`span`,{className:`stat-add`,children:[`+`,a]}),a>0&&o>0&&` `,o>0&&(0,S.jsxs)(`span`,{className:`stat-del`,children:[`−`,o]})]}),s,c,l]})}function os({layer:e,index:t,current:n,open:r,onToggleOpen:i,viewed:a,threadCount:o,onPick:s,onMarkFiles:c,onClearFiles:l}){let u=wo(e,a),d=u.files>0&&u.doneFiles===u.files,f=u.doneMarks>0,p=e.files.filter(e=>!po(e.file,a)).map(e=>e.file.path),m=e.files.map(e=>e.file.path);return(0,S.jsxs)(`div`,{className:`row row-layer${d?` row-done`:``}${e.derived?` row-layer-since`:``}`,"aria-current":n?`true`:void 0,"data-layer":e.id??`since`,onClick:()=>s(t),children:[(0,S.jsx)(`button`,{type:`button`,className:`row-box`,role:`checkbox`,"aria-checked":d?!0:f?`mixed`:!1,"aria-label":d?`Mark ${e.title} not reviewed`:`Mark ${rs(p.length,`file`)} in ${e.title} reviewed`,"data-tip":d?`Mark ${rs(m.length,`file`)} not reviewed`:`Mark ${rs(p.length,`file`)} reviewed`,disabled:m.length===0||(d?!l:!c),onClick:e=>{e.stopPropagation(),d?l?.(m):c?.(p)},children:(0,S.jsx)(Io,{state:d?!0:f?`mixed`:!1})}),(0,S.jsxs)(`button`,{type:`button`,className:`row-pick`,title:e.title,onClick:e=>{e.stopPropagation(),s(t)},children:[(0,S.jsx)(`span`,{className:`row-name`,children:(0,S.jsx)(`span`,{className:`row-base`,children:e.title})}),(0,S.jsxs)(`span`,{className:`ch-sub`,children:[u.doneMarks>0&&(0,S.jsx)(`span`,{className:`prog-track`,"aria-hidden":`true`,children:(0,S.jsx)(`i`,{style:{width:`${u.marks===0?0:Math.round(u.doneMarks/u.marks*100)}%`}})}),(0,S.jsx)(as,{layer:e,viewed:a})]})]}),(0,S.jsxs)(`span`,{className:`row-right`,children:[o>0&&(0,S.jsxs)(`span`,{className:`row-count`,title:rs(o,`thread`),children:[(0,S.jsx)(U,{name:`chat`,size:`sm`}),o]}),e.files.length>0&&(0,S.jsx)(`button`,{type:`button`,className:`row-act ch-fold chevron${r?``:` chevron-shut`}`,"aria-expanded":r,"aria-label":`${r?`Hide`:`Show`} the files in ${e.title}`,"data-tip":r?`Hide files`:`Show files`,onClick:e=>{e.stopPropagation(),i()},children:(0,S.jsx)(U,{name:`chev`,size:`sm`})})]})]})}function ss({layer:e,...t}){let n=(0,x.useMemo)(()=>e.files.map(e=>e.file),[e.files]),r=(0,x.useMemo)(()=>new Map(e.files.flatMap(e=>e.note?[[e.file.path,e.note]]:[])),[e.files]);return(0,S.jsx)(ts,{files:n,notes:r,...t})}function cs({layers:e,activeIndex:t,onPick:n,viewed:r,guide:i,description:a,overviewActive:o=!1,onOpenGuide:s,threads:c,attention:l,changed:u,selectedPath:d,onPickFile:f,onToggleFileViewed:p,onMarkFiles:m,onClearFiles:h,onAskFile:g,onRefresh:_,request:v=null}){let y=e=>e.files.reduce((e,t)=>e+(c?.get(t.file.path)?.length??0),0),[b,C]=(0,x.useState)(new Set),w=e=>b.has(e.id??`since`),T=e=>C(t=>{let n=new Set(t),r=e.id??`since`;return n.has(r)?n.delete(r):n.add(r),n});return(0,S.jsxs)(`div`,{className:`rail-scroll`,children:[(i||a)&&(0,S.jsxs)(`div`,{className:`row row-layer row-layer-overview`,"aria-current":o?`true`:void 0,onClick:s,children:[(0,S.jsx)(`span`,{className:`row-box`,"aria-hidden":`true`,children:(0,S.jsx)(Io,{})}),(0,S.jsxs)(`button`,{type:`button`,className:`row-pick`,title:a&&i?`The pull request description, and the agent’s guide to this change`:a?`The pull request description`:`The agent’s guide to this change`,onClick:e=>{e.stopPropagation(),s?.()},children:[(0,S.jsx)(`span`,{className:`row-name`,children:(0,S.jsx)(`span`,{className:`row-base`,children:`Overview`})}),(0,S.jsx)(`span`,{className:`ch-sub`,children:(0,S.jsx)(`span`,{children:a&&i?`the description, and the agent’s guide`:a?`the pull request description`:`the agent’s guide`})})]}),(0,S.jsx)(`span`,{className:`row-right`})]}),e.map((e,i)=>{let a=i===t,o=w(e);return(0,S.jsxs)(`div`,{className:`ch-layer`,children:[e.derived&&(0,S.jsx)(`div`,{className:`rail-rule`}),(0,S.jsx)(os,{layer:e,index:i,current:a,open:o,onToggleOpen:()=>T(e),viewed:r,threadCount:y(e),onPick:n,onMarkFiles:m,onClearFiles:h}),o&&e.files.length>0&&(0,S.jsx)(`div`,{className:`ch-files`,children:(0,S.jsx)(ss,{layer:e,viewed:r,selectedPath:d,threads:c,attention:l,changed:u,onPickFile:f,onToggleFileViewed:p,onMarkFiles:m,onClearFiles:h,onAskFile:g})})]},e.id??`since`)}),v===null?_?(0,S.jsx)(`button`,{type:`button`,className:`ch-foot ch-foot-act`,title:`the change moved on; a re-post keeps your place`,onClick:_,children:`Ask the agent to re-outline…`}):(0,S.jsx)(`div`,{className:`ch-foot`,title:`Invite one from the header`,children:`No agent attached to re-outline`}):(0,S.jsxs)(`div`,{className:`ch-foot ch-foot-live`,"aria-live":`polite`,children:[(0,S.jsxs)(`span`,{className:`ch-working`,"aria-hidden":`true`,children:[(0,S.jsx)(`i`,{}),(0,S.jsx)(`i`,{}),(0,S.jsx)(`i`,{})]}),` `,v===`outlining`?`re-outlining…`:`asked · waits for the open threads`]})]})}function ls({state:e,onOutline:t,onInvite:n}){if(e===`queued`||e===`outlining`){let t=e===`outlining`;return(0,S.jsx)(`div`,{className:`rail-scroll`,children:(0,S.jsxs)(`div`,{className:`ch-empty`,"data-state":e,"aria-live":`polite`,children:[(0,S.jsxs)(`h2`,{className:`ch-empty-title`,children:[(0,S.jsxs)(`span`,{className:`ch-working${t?``:` ch-working-idle`}`,"aria-hidden":`true`,children:[(0,S.jsx)(`i`,{}),(0,S.jsx)(`i`,{}),(0,S.jsx)(`i`,{})]}),t?`Outlining…`:`Asked`]}),(0,S.jsx)(`p`,{className:`ch-empty-sub`,children:t?`The steps appear here as soon as the agent posts them.`:`The agent starts once it finishes the threads it’s answering.`})]})})}return(0,S.jsx)(`div`,{className:`rail-scroll`,children:(0,S.jsxs)(`div`,{className:`ch-empty`,"data-state":e,"aria-live":`polite`,children:[(0,S.jsx)(`h2`,{className:`ch-empty-title`,children:`Read in layers`}),(0,S.jsx)(`p`,{className:`ch-empty-sub`,children:`The agent splits its change into steps you read in order.`}),e===`noagent`?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`p`,{className:`ch-empty-note`,children:`No agent is attached to outline it.`}),n&&(0,S.jsx)(`button`,{type:`button`,className:`btn ch-empty-cta`,onClick:n,children:`Invite an agent`})]}):(0,S.jsxs)(`button`,{type:`button`,className:`btn ch-empty-cta`,onClick:t,disabled:!t,children:[(0,S.jsx)(U,{name:`list`,size:`sm`}),`Ask the agent to outline`]})]})})}function us({tab:e,onSetTab:t,fileCount:n,threadCount:r,settledCount:i=0,wantsYou:a,layerCount:o=null,layersSuggested:s=!1,layers:c,files:l,threads:u}){return(0,S.jsxs)(`nav`,{className:`rail`,children:[(0,S.jsxs)(`div`,{className:`tabs`,role:`tablist`,"aria-label":`Files, threads, or layers`,children:[(0,S.jsxs)(`button`,{type:`button`,role:`tab`,className:`tab`,"aria-selected":e===`files`,onClick:()=>t(`files`),children:[`Files `,(0,S.jsx)(`span`,{className:`tab-n`,children:n})]}),(0,S.jsxs)(`button`,{type:`button`,role:`tab`,className:`tab`,"aria-selected":e===`threads`,onClick:()=>t(`threads`),title:i>0?`${r} still going · ${i} settled`:void 0,children:[a>0&&(0,S.jsx)(`span`,{className:`tab-dot`,"aria-hidden":`true`}),`Threads `,(0,S.jsx)(`span`,{className:`tab-n`,children:r})]}),(0,S.jsxs)(`button`,{type:`button`,role:`tab`,className:`tab`,"aria-selected":e===`layers`,onClick:()=>t(`layers`),title:o===null?`The agent’s reading plan, once it posts one`:void 0,children:[s&&o===null&&(0,S.jsx)(`span`,{className:`tab-dot`,"aria-hidden":`true`}),`Layers `,o!==null&&(0,S.jsx)(`span`,{className:`tab-n`,children:o})]})]}),e===`layers`?c:e===`files`?l:u]})}var ds=(0,x.createContext)(null);function fs(){return(0,x.useContext)(ds)}function ps(e){return e.state===`resolved`?`resolved`:it(e)?e.state===`open`&&!e.github?`note`:`posted`:lt(e)&&e.state===`open`?`proposed`:e.state===`open`?`note`:e.messages.at(-1)?.author===`agent`?e.awaitingFollowUp===!0?`agent`:`yours`:e.withheld?`note`:e.unanswered?e.state===`addressed`?`yours`:`unanswered`:`agent`}function ms(e){return(e.state===`open`||e.withheld===!0)&&!lt(e)&&!it(e)}var hs=[`yours`,`unanswered`,`proposed`,`agent`,`note`,`posted`,`resolved`],gs={yours:`Your turn`,unanswered:`No answer`,proposed:`From the agent`,agent:`Waiting on agent`,note:`Draft`,posted:`On GitHub`,resolved:`Resolved`},_s=[`yours`,`proposed`,`agent`,`note`,`posted`,`settled`],vs={yours:`Your turn`,proposed:`From the agent`,agent:`Waiting on the agent`,note:`Drafts`,posted:`On GitHub`,settled:`Settled`};function ys(e){switch(e){case`yours`:case`unanswered`:return`yours`;case`proposed`:return`proposed`;case`agent`:return`agent`;case`note`:return`note`;case`posted`:return`posted`;case`resolved`:return`settled`}}function bs(e){if(e.state===`open`||e.state===`resolved`||it(e))return null;let t=e.messages.at(-1)?.author===`agent`&&e.awaitingFollowUp!==!0,n=e.state===`addressed`;return t?n?`fixed`:`answered`:n?`changed`:e.unanswered?`no-answer`:`waiting`}function xs(e){for(let t of e.split(`
79
+ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+Li(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function J(e,t){return ea.parse(e,t)}J.options=J.setOptions=function(e){return ea.setOptions(e),J.defaults=ea.defaults,hr(J.defaults),J},J.getDefaults=pr,J.defaults=mr;function ta(...e){return ea.use(...e),J.defaults=ea.defaults,hr(J.defaults),J}J.use=ta,J.walkTokens=function(e,t){return ea.walkTokens(e,t)},J.parseInline=ea.parseInline,J.Parser=Qi,J.parser=Qi.parse,J.Renderer=Zi,J.TextRenderer=q,J.Lexer=Xi,J.lexer=Xi.lex,J.Tokenizer=Yi,J.Hooks=$i,J.parse=J,J.options,J.setOptions,J.walkTokens,J.parseInline,Qi.parse,Xi.lex,J.setOptions({gfm:!0,breaks:!0});var na=[`p`,`br`,`hr`,`strong`,`em`,`del`,`code`,`pre`,`blockquote`,`ul`,`ol`,`li`,`a`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`table`,`thead`,`tbody`,`tr`,`th`,`td`],ra=fr(),ia=!1;function aa(){ia||(ia=!0,ra.addHook(`afterSanitizeAttributes`,e=>{if(e instanceof Element&&(e.tagName===`A`&&e.hasAttribute(`href`)&&!(e.getAttribute(`href`)??``).startsWith(`#`)&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`)),e.hasAttribute(`class`))){let t=/^language-[\w+-]+$/.exec(e.getAttribute(`class`)??``);e.tagName===`CODE`&&t?e.setAttribute(`class`,t[0]):e.removeAttribute(`class`)}}))}function oa(e){aa();let t=J.parse(e,{async:!1});return ra.sanitize(t,{ALLOWED_TAGS:na,ALLOWED_ATTR:[`href`,`title`,`target`,`rel`,`class`],ALLOWED_URI_REGEXP:/^(?:https?:|mailto:|#)/i})}var sa=[...na,`img`,`picture`,`source`,`div`,`span`,`details`,`summary`],ca=fr(),la=``;function ua(e,t){let n=t.split(/[?#]/,1)[0]??``,r=n.startsWith(`/`)?n.slice(1):e?`${e}/${n}`:n,i=[];for(let e of r.split(`/`))e!==``&&e!==`.`&&(e===`..`?i.pop():i.push(e));return i.join(`/`)}function da(e){return`/api/file?path=${encodeURIComponent(ua(la,e))}&side=head`}var fa=/^(?:[a-z][a-z0-9+.-]*:|\/\/|#)/i,pa=/^(?:https?:|mailto:|#)/i,ma=!1;function ha(){ma||(ma=!0,ca.addHook(`uponSanitizeAttribute`,(e,t)=>{let{attrName:n,attrValue:r}=t;n===`src`||n===`href`?fa.test(r)?pa.test(r)||(t.keepAttr=!1):t.attrValue=da(r):n===`srcset`&&(t.attrValue=r.split(`,`).map(e=>{let[t,...n]=e.trim().split(/\s+/);return t?fa.test(t)?pa.test(t)?[t,...n].join(` `):``:[da(t),...n].join(` `):``}).filter(Boolean).join(`, `))}),ca.addHook(`afterSanitizeAttributes`,e=>{if(e instanceof Element&&(e.tagName===`A`&&e.hasAttribute(`href`)&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`)),e.hasAttribute(`class`))){let t=/^language-[\w+-]+$/.exec(e.getAttribute(`class`)??``);e.tagName===`CODE`&&t?e.setAttribute(`class`,t[0]):e.removeAttribute(`class`)}}))}function ga(e,t){ha();let n=t.lastIndexOf(`/`);la=n===-1?``:t.slice(0,n);let r=J.parse(e,{async:!1});return ca.sanitize(r,{ALLOWED_TAGS:sa,ALLOWED_ATTR:[`href`,`title`,`target`,`rel`,`class`,`src`,`srcset`,`alt`,`width`,`height`,`media`,`align`,`open`]})}function _a(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);if(Number.isNaN(n))return e;let r=Math.round((t-n)/1e3);if(r<45)return`just now`;let i=Math.round(r/60);if(i<60)return`${i} minute${i===1?``:`s`} ago`;let a=Math.round(i/60);if(a<24)return`${a} hour${a===1?``:`s`} ago`;let o=Math.round(a/24);return o<7?`${o} day${o===1?``:`s`} ago`:new Date(n).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function va(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);if(Number.isNaN(n))return``;let r=Math.max(0,Math.round((t-n)/1e3));if(r<60)return`${r}s`;let i=Math.round(r/60);if(i<60)return`${i}m`;let a=Math.round(i/60);if(a<24)return`${a}h`;let o=Math.round(a/24);return o<7?`${o}d`:new Date(n).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}var ya=30,ba=22,xa=48,Sa=1100,Ca=1500,wa=1.1,Ta=3e3,Ea=110,Da=560,Oa=64,ka=90/24,Aa=ya*3.5/24,ja=540/24,Ma={shut:`M7.8 10.4h2.4M13.8 10.4h2.4`,plus:`M7.8 10.2h2.4M9 9v2.4M13.8 10.2h2.4M15 9v2.4`,happy:`M7.8 11l1.2-1.4 1.2 1.4M13.8 11l1.2-1.4 1.2 1.4`},Na=new Set([`stand`,`sit`]);function Pa(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}var Fa=(e,t)=>e+Math.random()*(t-e),Ia=e=>`translate(${e.x}px, ${e.y}px) scale(${e.s})`;function La({presence:e,reason:t,seat:n,onAway:r,summon:i=0}){let a=(0,x.useRef)(null),o=(0,x.useRef)(null),[s,c]=(0,x.useState)(!1),l=(0,x.useRef)(!1),u=(0,x.useRef)(r);u.current=r;let d=(0,x.useCallback)(e=>{l.current=e,c(e),u.current?.(e)},[]),[f,p]=(0,x.useState)(!1),m=(0,x.useRef)(null),h=(0,x.useRef)(0),g=(0,x.useRef)(!1),_=(0,x.useRef)(i),[v,y]=(0,x.useState)(0),[b,C]=(0,x.useState)(null),[w,T]=(0,x.useState)(null),[E,D]=(0,x.useState)(`stand`),[O,k]=(0,x.useState)(null),A=(0,x.useRef)(null);A.current=b;let[j,M]=(0,x.useState)(!1),N=(0,x.useRef)(!1);N.current=j;let[P,F]=(0,x.useState)(!1);(0,x.useEffect)(()=>{let e,t=t=>{N.current||M(!0),t.type===`keydown`&&F(!0),clearTimeout(e),e=setTimeout(()=>{M(!1),F(!1)},Ta)},n={capture:!0,passive:!0},r=[`pointermove`,`wheel`,`scroll`,`keydown`];for(let e of r)addEventListener(e,t,n);return()=>{clearTimeout(e);for(let e of r)removeEventListener(e,t,n)}},[]),(0,x.useEffect)(()=>{let e=a.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(([e])=>e&&y(e.contentRect.width));return t.observe(e),()=>t.disconnect()},[]);let I=(0,x.useRef)(t);(0,x.useEffect)(()=>{t===`replied`&&I.current!==`replied`&&!Pa()&&k(`approve`),I.current=t},[t]);let ee=Na.has(E)&&!O;(0,x.useEffect)(()=>{let e=o.current,t=e?.querySelector(`.critter-look`);if(!e||!t)return;if(!ee||Pa()){t.style.transform=``;return}let n=0,r=r=>{n||=requestAnimationFrame(()=>{n=0;let i=e.getBoundingClientRect(),a=r.clientX-(i.left+i.width/2),o=r.clientY-(i.top+i.height*.4),s=Math.hypot(a,o)||1;t.style.transform=`translate(${a/s*wa}px, ${o/s*wa*.8}px)`})};return addEventListener(`pointermove`,r),()=>{removeEventListener(`pointermove`,r),cancelAnimationFrame(n),t.style.transform=``}},[ee]);let te=Math.max(0,v-ya),ne=(0,x.useRef)(te);ne.current=te;let L=v>0,re=e===`waiting`||te<Oa||Pa();(0,x.useEffect)(()=>()=>u.current?.(!1),[]),(0,x.useLayoutEffect)(()=>{!s&&m.current&&(m.current.anim.cancel(),m.current=null)},[s]),(0,x.useEffect)(()=>{if(!L)return;let t=()=>ne.current,r,s=!0,c=()=>Math.min(A.current??t(),t()),u=(e,t)=>{r=setTimeout(()=>s&&t(),e)},f=(e,t,n)=>{D(e),u(t,n)},v=(e,t,n)=>{let r=c(),i=Math.abs(e-r)/t*1e3;if(i<150){n();return}D(`walk`),T({ms:i,dir:e<r?`left`:`right`}),C(e),u(i,()=>{T(null),n()})},y=()=>{let e=n?.current?n.current.getBoundingClientRect():void 0,t=a.current?.getBoundingClientRect(),r=o.current;if(!e?.width||!t||!r)return null;let i=e.width/ja;return{x:e.left-t.left-ka*i,y:e.top+e.height/30-t.top-r.offsetTop-Aa*i,s:i}},b=(e,t,n,r)=>{let i=o.current;if(!i||typeof i.animate!=`function`){r();return}let a={x:(e.x+t.x)/2,y:Math.min(e.y,t.y)-16,s:(e.s+t.s)/2},s=i.animate([e,a,t].map(e=>({transform:Ia(e)})),{duration:Da,easing:`cubic-bezier(0.3, 0.7, 0.4, 1)`,fill:`forwards`});m.current={anim:s,home:n},u(Da,r)},x=()=>{p(!1),d(!1)},S=e=>{v(t(),Ea,()=>{let t=y();if(!t){x(),e?.();return}D(`stand`),p(!0),b({x:c(),y:0,s:1},t,!0,()=>{x(),e?.()})})},w=e=>{let n=y();if(C(t()),D(`stand`),p(!0),d(!0),!n){p(!1),e();return}b(n,{x:t(),y:0,s:1},!1,()=>{m.current?.anim.cancel(),m.current=null,p(!1),e()})},E=()=>{if(e===`working`){let e=()=>c()>t()/2?Fa(0,t()*.4):Fa(t()*.6,t()),n=()=>Math.random()<.5?`inspect`:`write`,r=()=>N.current?f(n(),Fa(2500,4e3),r):v(e(),xa,()=>f(n(),Fa(2500,5e3),()=>Math.random()<.4?f(`think`,Fa(1500,2800),r):r()));f(n(),Fa(1500,3e3),r)}else{let e=()=>{let n=Math.random();N.current?f(n<.5?`stand`:`read`,Fa(3e3,6e3),e):n<.3?f(`read`,Fa(4e3,8e3),e):n<.5?f(`stand`,Fa(3e3,6e3),e):n<.75?v(Fa(0,t()),ba,e):n<.9?f(`sit`,Fa(4e3,8e3),e):f(`think`,Fa(2e3,3500),e)};f(`read`,Fa(3e3,5e3),e)}},j=()=>u(Math.max(e===`working`?Fa(300,700):Fa(1e3,2500),h.current-Date.now()),()=>w(E)),M=i!==_.current;if(_.current=i,M&&!O&&!re&&!l.current)w(()=>k(`poke`));else if(M&&!O&&l.current)k(`poke`);else if(O&&l.current)f(O,O===`poke`?Sa:Ca,()=>{O===`approve`&&(g.current=!0),k(null)});else if(O)k(null);else if(re)l.current&&!Pa()?S():l.current&&x(),D(e===`waiting`?`sleep`:`stand`);else if(l.current&&(P||g.current)){let e=g.current;g.current=!1,e&&(h.current=Date.now()+Fa(4e3,6e3)),S(P?void 0:j)}else l.current?E():(D(`stand`),P||j());return()=>{if(s=!1,clearTimeout(r),m.current){let{anim:e,home:t}=m.current;e.cancel(),m.current=null,p(!1),t&&d(!1),T(null);return}let e=o.current;if(e)try{C(new DOMMatrixReadOnly(getComputedStyle(e).transform).m41)}catch{}T(null)}},[e,L,O,P,re,n,d,i]);let ie=()=>{!O&&!Pa()&&k(`poke`)},ae={transform:Ia({x:Math.min(b??te,te),y:0,s:1}),transition:w?`transform ${w.ms}ms linear`:`none`,visibility:v&&s?void 0:`hidden`};return(0,S.jsx)(`span`,{className:`critter-track`,ref:a,children:(0,S.jsx)(`span`,{ref:o,className:`critter-walker${w?` critter-moving critter-${w.dir}`:``}${j?` critter-calm`:``}${f?` critter-tucked`:``}`,style:ae,onPointerEnter:ie,children:(0,S.jsx)(Ra,{presence:e,act:E})})})}function Ra({presence:e,act:t=e===`waiting`?`sleep`:`stand`,size:n=ya}){return(0,S.jsxs)(`svg`,{className:`critter critter-${e} critter-act-${t}`,width:n,height:n,viewBox:`0 0 24 24`,"aria-hidden":`true`,focusable:`false`,children:[(0,S.jsxs)(`g`,{className:`critter-figure`,children:[(0,S.jsx)(`rect`,{className:`critter-leg critter-leg-l`,x:`7`,y:`16.5`,width:`3`,height:`4.5`,rx:`1`}),(0,S.jsx)(`rect`,{className:`critter-leg critter-leg-r`,x:`14`,y:`16.5`,width:`3`,height:`4.5`,rx:`1`}),(0,S.jsxs)(`g`,{className:`critter-torso`,children:[(0,S.jsx)(`rect`,{className:`critter-body`,x:`3`,y:`3.5`,width:`18`,height:`14`,rx:`4`}),(0,S.jsxs)(`g`,{className:`critter-look`,children:[(0,S.jsx)(`path`,{className:`critter-eyes critter-eyes-shut`,d:Ma.shut}),(0,S.jsxs)(`g`,{className:`critter-eyes-open`,children:[(0,S.jsx)(`rect`,{x:`8.1`,y:`8.6`,width:`1.8`,height:`3.1`,rx:`0.9`}),(0,S.jsx)(`rect`,{x:`14.1`,y:`8.6`,width:`1.8`,height:`3.1`,rx:`0.9`})]}),(0,S.jsx)(`path`,{className:`critter-eyes critter-eyes-plus`,d:Ma.plus}),(0,S.jsx)(`path`,{className:`critter-eyes critter-eyes-happy`,d:Ma.happy})]}),(0,S.jsxs)(`g`,{className:`critter-glasses`,children:[(0,S.jsx)(`circle`,{cx:`9`,cy:`10.2`,r:`3`}),(0,S.jsx)(`circle`,{cx:`15`,cy:`10.2`,r:`3`})]})]}),(0,S.jsxs)(`g`,{className:`critter-page`,children:[(0,S.jsx)(`rect`,{x:`6.2`,y:`13.2`,width:`11.6`,height:`7`,rx:`1`}),(0,S.jsx)(`path`,{className:`critter-line-del`,d:`M8 15.1h4`}),(0,S.jsx)(`path`,{className:`critter-line-ctx`,d:`M8 16.7h6.5`}),(0,S.jsx)(`path`,{className:`critter-line-add`,pathLength:`1`,d:`M8 18.3h5.5`})]}),(0,S.jsxs)(`g`,{className:`critter-hands`,children:[(0,S.jsx)(`circle`,{cx:`6.2`,cy:`17`,r:`1.4`}),(0,S.jsx)(`circle`,{cx:`17.8`,cy:`17`,r:`1.4`})]}),(0,S.jsxs)(`g`,{className:`critter-pen`,children:[(0,S.jsx)(`path`,{d:`M14.6 19l3.4-3.6`}),(0,S.jsx)(`circle`,{cx:`18.3`,cy:`15.3`,r:`1.4`})]}),(0,S.jsxs)(`g`,{className:`critter-mag`,children:[(0,S.jsx)(`circle`,{className:`critter-lens`,cx:`21.6`,cy:`13.4`,r:`3`}),(0,S.jsx)(`path`,{d:`M23.7 15.6l2 2`}),(0,S.jsx)(`circle`,{className:`critter-mag-hand`,cx:`25.8`,cy:`17.7`,r:`1.4`})]})]}),(0,S.jsxs)(`g`,{className:`critter-z`,children:[(0,S.jsx)(`path`,{className:`critter-z-a`,d:`M17.5 0.5h3l-3 3h3`}),(0,S.jsx)(`path`,{className:`critter-z-b`,d:`M21.5 -4.5h4l-4 4h4`})]}),(0,S.jsxs)(`g`,{className:`critter-thought`,children:[(0,S.jsx)(`circle`,{cx:`20.5`,cy:`2.6`,r:`0.9`}),(0,S.jsx)(`circle`,{cx:`22.6`,cy:`0.2`,r:`1.15`}),(0,S.jsx)(`circle`,{cx:`25.2`,cy:`-2.6`,r:`1.4`})]}),(0,S.jsx)(`path`,{className:`critter-spark critter-spark-a`,d:`M19.5 1.5h2.4M20.7 0.3v2.4`}),(0,S.jsx)(`path`,{className:`critter-spark critter-spark-b`,d:`M2.5 2.5h2.4M3.7 1.3v2.4`}),(0,S.jsxs)(`g`,{className:`critter-badge`,children:[(0,S.jsx)(`circle`,{cx:`12`,cy:`-2.5`,r:`3`}),(0,S.jsx)(`path`,{d:`M10.6 -2.5l1 1 1.9-2`})]})]})}function za({eyes:e}){return(0,S.jsxs)(`svg`,{className:`critter-face`,width:`18`,height:`15`,viewBox:`3 3 18 15`,"aria-hidden":`true`,focusable:`false`,children:[(0,S.jsx)(`rect`,{x:`3`,y:`3.5`,width:`18`,height:`14`,rx:`4`}),e===`open`?(0,S.jsxs)(`g`,{className:`critter-face-open`,children:[(0,S.jsx)(`rect`,{x:`8.1`,y:`8.6`,width:`1.8`,height:`3.1`,rx:`0.9`}),(0,S.jsx)(`rect`,{x:`14.1`,y:`8.6`,width:`1.8`,height:`3.1`,rx:`0.9`})]}):(0,S.jsx)(`path`,{className:`critter-face-eyes`,d:Ma[e]})]})}function Ba({size:e=24,className:t,label:n}){return(0,S.jsx)(`svg`,{className:t?`icon living-mark ${t}`:`icon living-mark`,width:e,height:e,viewBox:`0 0 24 24`,focusable:`false`,"aria-hidden":!n||void 0,role:n?`img`:void 0,"aria-label":n,children:(0,S.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,children:[(0,S.jsx)(`path`,{className:`lm-minus`,d:`M3.3 7.4h2.6`}),(0,S.jsx)(`path`,{className:`lm-plus-h`,d:`M3.3 16.6h2.6`}),(0,S.jsx)(`path`,{className:`lm-plus-v`,d:`M4.6 15.3v2.6`}),(0,S.jsx)(`path`,{className:`lm-l1`,d:`M9.3 7.4H20.4`}),(0,S.jsx)(`path`,{d:`M9.3 12h8`}),(0,S.jsx)(`path`,{className:`lm-l3`,d:`M9.3 16.6h10.2`})]})})}function Va({label:e,icon:t=`more`,children:n,align:r=`right`,triggerClassName:i=`btn btn-ghost btn-icon btn-sm`}){let[a,o]=(0,x.useState)(!1),s=(0,x.useRef)(null);return(0,x.useEffect)(()=>{if(!a)return;let e=e=>{s.current?.contains(e.target)||o(!1)},t=e=>{e.key===`Escape`&&(e.stopPropagation(),o(!1))};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t,!0),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t,!0)}},[a]),(0,S.jsxs)(`div`,{className:`menu`,ref:s,children:[(0,S.jsx)(`button`,{type:`button`,className:i,"aria-label":e,"data-tip":a?void 0:e,"aria-haspopup":`menu`,"aria-expanded":a,onClick:e=>{e.stopPropagation(),o(e=>!e)},children:(0,S.jsx)(U,{name:t})}),a&&(0,S.jsx)(`div`,{className:`menu-panel${r===`left`?` menu-panel-left`:``}`,role:`menu`,children:n(()=>o(!1))})]})}function Ha({icon:e,kbd:t,checked:n,danger:r=!1,onClick:i,children:a}){return(0,S.jsxs)(`button`,{type:`button`,role:n===void 0?`menuitem`:`menuitemradio`,...n===void 0?{}:{"aria-checked":n},className:`menu-item${r?` menu-item-danger`:``}`,onClick:i,children:[e&&(0,S.jsx)(U,{name:e,size:`sm`}),(0,S.jsx)(`span`,{className:`menu-item-label`,children:a}),n&&(0,S.jsx)(U,{name:`check`,size:`sm`,className:`menu-item-check`}),t&&(0,S.jsx)(`span`,{className:`kbd`,children:t})]})}function Ua(){return(0,S.jsx)(`hr`,{className:`menu-sep`})}function Wa({children:e}){return(0,S.jsx)(`div`,{className:`menu-label`,children:e})}function Ga({changeset:e}){let{spec:t,repo:n,pr:r}=e;if(r)return null;let i=t.kind===`working-tree`,a=i?`working tree`:n.branch||`HEAD`,o=i?`HEAD`:t.base,s=[i?`comparing your working tree against HEAD${n.branch?` on branch ${n.branch}`:``}`:`comparing ${a} against ${o}`,n.worktree&&`linked worktree '${n.worktree}'`].filter(Boolean).join(` · `);return(0,S.jsxs)(`span`,{className:`cmp`,title:s,children:[(0,S.jsx)(`span`,{className:`repo`,children:n.name}),(0,S.jsx)(`span`,{className:`cmp-dot`,"aria-hidden":`true`,children:`·`}),(0,S.jsx)(`span`,{className:`cmp-side`,children:a}),(0,S.jsx)(U,{name:`arrow`,size:`sm`,className:`cmp-arrow`}),(0,S.jsx)(`span`,{className:`cmp-side cmp-side-base`,children:o})]})}var Ka={success:`CI passing`,failure:`CI failing`,pending:`CI running`,none:`no checks`,unknown:`checks not visible to your token`};function qa(e){return e.state===`open`?e.changesRequested>0?{label:`changes requested`,className:`chip-attn`}:e.checks.state===`failure`?{label:`CI failing`,className:`pr-check-failure`}:e.draft?{label:`draft`,className:`chip-mute pr-state pr-state-draft`}:e.checks.state===`pending`?{label:`CI running`,className:`pr-check-pending`}:null:{label:e.state,className:`chip-mute pr-state pr-state-${e.state}`}}function Ja({user:e,large:t=!1}){let n=t?`pr-avatar pr-avatar-lg`:`pr-avatar`;return e.avatarUrl?(0,S.jsx)(`img`,{className:n,src:e.avatarUrl,alt:``}):(0,S.jsx)(`span`,{className:`${n} pr-avatar-none`,children:(0,S.jsx)(U,{name:`user`,size:t?`md`:`sm`})})}var Ya=e=>{let t=va(e);return/^\d/.test(t)?`${t} ago`:t};function Xa({pr:e}){let[t,n]=(0,x.useState)(!1),r=e.commits.at(-1),i=[Ka[e.checks.state],r?`pushed ${Ya(r.at)}`:``].filter(Boolean).join(` · `),a=e.approvals===0&&e.changesRequested===0?{text:`no reviews yet`,tone:`mute`}:e.changesRequested>0?{text:`changes requested${e.approvals>0?` · ${e.approvals} ${e.approvals===1?`approval`:`approvals`}`:``}`,tone:`attn`}:{text:`${e.approvals} ${e.approvals===1?`approval`:`approvals`}`,tone:`ok`},o=e.commits.length,s=t=>`https://${e.host}/${e.owner}/${e.repo}/pull/${e.number}/commits/${t}`;return(0,S.jsxs)(`section`,{className:`menu-panel menu-panel-left pr-card`,"aria-label":`pull request details`,children:[(0,S.jsxs)(`div`,{className:`pr-card-who`,children:[(0,S.jsx)(Ja,{user:e.author,large:!0}),(0,S.jsxs)(`span`,{className:`pr-card-who-text`,children:[(0,S.jsx)(`span`,{className:`pr-card-login`,children:e.author.login}),(0,S.jsxs)(`span`,{className:`pr-card-where`,children:[e.owner,`/`,e.repo,` #`,e.number]})]})]}),(0,S.jsxs)(`div`,{className:`pr-card-body`,children:[(0,S.jsxs)(`div`,{className:`pr-card-refs`,title:`${e.head.ref} into ${e.base.ref}`,children:[(0,S.jsx)(`code`,{className:`pr-ref`,children:e.head.ref}),(0,S.jsx)(U,{name:`arrow`,size:`sm`,className:`cmp-arrow`}),(0,S.jsx)(`code`,{className:`pr-ref pr-ref-base`,children:e.base.ref})]}),(0,S.jsxs)(`ul`,{className:`pr-card-facts`,children:[(0,S.jsxs)(`li`,{className:`pr-fact pr-fact-${e.checks.state}`,children:[(0,S.jsx)(`i`,{className:`pr-fact-dot`,"aria-hidden":`true`}),e.checks.url?(0,S.jsx)(`a`,{href:e.checks.url,target:`_blank`,rel:`noreferrer`,children:i}):i]}),(0,S.jsxs)(`li`,{className:`pr-fact pr-fact-${a.tone}`,children:[(0,S.jsx)(U,{name:a.tone===`ok`?`check`:a.tone===`attn`?`alert`:`chat`,size:`sm`}),a.text]})]}),o>0&&(0,S.jsxs)(`div`,{className:`pr-commits`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`pr-commits-toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[(0,S.jsx)(`span`,{className:`chevron${t?``:` chevron-shut`}`,children:(0,S.jsx)(U,{name:`chev`,size:`sm`})}),o,` `,o===1?`commit`:`commits`]}),t&&(0,S.jsx)(`ol`,{className:`pr-commit-list`,children:[...e.commits].reverse().map(e=>(0,S.jsx)(`li`,{children:(0,S.jsxs)(`a`,{className:`pr-commit`,href:s(e.sha),target:`_blank`,rel:`noreferrer`,title:`${e.subject}${e.author?`, by ${e.author.login}`:``}, opens on GitHub`,children:[(0,S.jsx)(`code`,{className:`pr-commit-sha`,children:e.sha.slice(0,7)}),(0,S.jsx)(`span`,{className:`pr-commit-subject`,children:e.subject}),(0,S.jsx)(`span`,{className:`pr-commit-ago`,children:va(e.at)})]})},e.sha))})]})]}),(0,S.jsxs)(`a`,{className:`btn btn-ghost pr-card-link`,href:e.url,target:`_blank`,rel:`noreferrer`,children:[`Open on GitHub`,(0,S.jsx)(U,{name:`link`,size:`sm`})]})]})}function Za({pr:e}){let[t,n]=(0,x.useState)(!1),r=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(!t)return;let e=e=>{r.current?.contains(e.target)||n(!1)},i=e=>{e.key===`Escape`&&(e.stopPropagation(),n(!1))};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,i,!0),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,i,!0)}},[t]);let i=qa(e);return(0,S.jsxs)(`span`,{className:`where pr-chips menu`,ref:r,children:[(0,S.jsxs)(`button`,{type:`button`,className:`pr-title`,"aria-haspopup":`dialog`,"aria-expanded":t,onClick:()=>n(e=>!e),title:t?void 0:`${e.owner}/${e.repo}#${e.number}: author, branches, checks, reviews`,children:[(0,S.jsx)(U,{name:`pr`,size:`sm`}),(0,S.jsxs)(`span`,{className:`pr-number`,children:[`#`,e.number]}),(0,S.jsx)(`span`,{className:`pr-title-text`,children:e.title})]}),i&&(0,S.jsx)(`span`,{className:`chip ${i.className}`,children:i.label}),t&&(0,S.jsx)(Xa,{pr:e})]})}var Qa={waiting:`no agent is attached; sends queue for the next poll, and the prompt is copied so you can paste it yourself`,listening:`your agent is here and listening; anything you send reaches it right away`,working:`the agent received feedback and is working on it`},$a=`the agent is attached but its last poll ended; a send queues and reaches it when it polls again`,eo=`your agent opened this review and is reading the change before it starts listening — its guide lands first; a send queues and reaches it at its first poll`,to=/^(working on|answered|picked up|outlining) (.+)$/,no=e=>e.charAt(0).toUpperCase()+e.slice(1);function ro(e,t,n,r){if(e===`waiting`)return r?{verb:`Invite`,detail:`your agent`}:{verb:`No agent`};if(e===`listening`)return{verb:`Listening`};if(n){let e=to.exec(n);return e?{verb:no(e[1]),detail:e[2]}:{verb:no(n)}}return t===`arriving`?{verb:`Reading`,detail:`the change`}:t===`repolling`?{verb:`Paused`,detail:`sends wait`}:{verb:`Working`}}function io(e,t,n){return n?`happy`:e===`waiting`?`shut`:e===`listening`||t===`arriving`||t===`repolling`?`open`:`plus`}function ao(e,t){return e===`working`?t===`repolling`?$a:t===`arriving`?eo:Qa[e]:Qa[e]}function oo(e){let t=Math.max(0,Math.round(e/1e3));return t<60?`${t}s`:`${Math.round(t/60)}m`}function so({presence:e,reason:t,since:n,activity:r,onInvite:i,batch:a,monitorOpen:o=!1,onOpenMonitor:s,monitorPanel:c,suggestion:l,seat:u,faceAway:d=!1,onHover:f}){let[,p]=(0,x.useState)(0),m=(0,x.useRef)(null),h=e===`working`&&typeof n==`number`;(0,x.useEffect)(()=>{if(!h)return;let e=setInterval(()=>p(e=>e+1),1e4);return()=>clearInterval(e)},[h]),(0,x.useEffect)(()=>{if(!o||!s)return;let e=e=>{m.current?.contains(e.target)||s(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[o,s]);let[g,_]=(0,x.useState)(!1),v=(0,x.useRef)(t);(0,x.useEffect)(()=>{let e=v.current;if(v.current=t,t!==`replied`||e===`replied`)return;_(!0);let n=setTimeout(()=>_(!1),1500);return()=>{clearTimeout(n),_(!1)}},[t]);let y=a?.segments.length??0,b=e!==`waiting`&&!!l&&y===0,C=b?{verb:`Suggests`,detail:`layers`}:ro(e,t,r,e===`waiting`&&!!i),w=e===`waiting`?void 0:f,T=(0,S.jsx)(`span`,{className:`presence-face${d?` presence-face-away`:``}${g?` presence-face-cheer`:``}`,ref:u,"aria-hidden":`true`,children:(0,S.jsx)(za,{eyes:b?`happy`:io(e,t,g)})}),E=(0,S.jsxs)(S.Fragment,{children:[T,(0,S.jsxs)(`span`,{className:`presence-label`,children:[(0,S.jsx)(`span`,{className:`presence-verb`,children:C.verb}),C.detail&&(0,S.jsxs)(S.Fragment,{children:[` `,(0,S.jsx)(`span`,{className:`presence-detail`,children:C.detail})]}),h&&(0,S.jsxs)(`span`,{className:`presence-ago`,children:[` · `,oo(Date.now()-n)]})]})]});if(e===`waiting`&&i)return(0,S.jsx)(`button`,{type:`button`,className:`presence presence-waiting presence-invite`,onClick:i,title:`bring your agent into this review`,children:E});if(b)return(0,S.jsxs)(`button`,{type:`button`,className:`presence presence-${e} presence-suggests`,onClick:l.onOutline,onPointerEnter:w,title:l.reason?`the agent suggests reading this in layers: “${l.reason}”`:`the agent suggests reading this in layers`,children:[E,(0,S.jsx)(`span`,{className:`presence-cta`,children:`Ask it`})]});if(e===`waiting`||y===0||!s)return(0,S.jsx)(`span`,{className:`presence presence-${e}`,title:ao(e,t),onPointerEnter:w,children:E});let D=Math.round(a.done/y*100);return(0,S.jsxs)(`div`,{className:`menu monitor-anchor`,ref:m,children:[(0,S.jsxs)(`button`,{type:`button`,className:`presence presence-${e} presence-batch`,"aria-haspopup":`dialog`,"aria-expanded":o,onClick:()=>s(!o),onPointerEnter:w,title:`${Qa[e]}. ${a.done} of ${y} answered; click to watch the queue`,children:[D>0&&(0,S.jsx)(`span`,{className:`presence-fill`,style:{width:`${D}%`},"aria-hidden":`true`}),E,` `,(0,S.jsxs)(`span`,{className:`presence-batch-n`,children:[a.done,`/`,y]})]}),o&&c]})}function co({changeset:e,agent:t={},review:n={},settings:r={}}){let{openComments:i=0,publicDrafts:a=0,onFinishReview:o}=n,s=(0,x.useRef)(null),[c,l]=(0,x.useState)(!1),[u,d]=(0,x.useState)(0),{theme:f,onSetTheme:p,critter:m=!0,onSetCritter:h,onShowShortcuts:g,onShowPrivacy:_}=r;return(0,S.jsxs)(`header`,{className:`top`,children:[(0,S.jsxs)(`span`,{className:`mark`,children:[(0,S.jsx)(Ba,{size:36}),(0,S.jsx)(`span`,{className:`wordmark`,role:`img`,"aria-label":`Diffo`,children:[...`Diffo`].map((e,t)=>(0,S.jsx)(`span`,{className:`wordmark-letter`,style:{"--i":t},"aria-hidden":`true`,children:e},t))}),Rt()&&(0,S.jsx)(`span`,{className:`dev-badge`,title:`this review is served by a diffo running from a source checkout, not the released CLI`,children:`dev`})]}),e.pr&&(0,S.jsx)(Za,{pr:e.pr}),(0,S.jsx)(Ga,{changeset:e}),t.presence&&m?(0,S.jsx)(La,{presence:t.presence,reason:t.reason,seat:s,onAway:l,summon:u}):(0,S.jsx)(`span`,{className:`grow`}),t.presence&&(0,S.jsx)(so,{presence:t.presence,reason:t.reason,since:t.since,activity:t.activity,onInvite:t.onInvite,batch:t.batch,monitorOpen:t.monitorOpen,onOpenMonitor:t.onOpenMonitor,monitorPanel:t.monitorPanel,suggestion:t.suggestion,seat:s,faceAway:m&&c,onHover:m?()=>d(e=>e+1):void 0}),o&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:o,title:e.pr?a>0?`submit your review on GitHub with ${a} pending ${a===1?`comment`:`comments`}; private threads go to your agent`:`submit your review on GitHub; private threads and coverage go to your agent`:`finish review: send open comments + coverage to your agent`,children:e.pr?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(U,{name:`globe`,size:`sm`}),` Submit review`,a>0?` (${a})`:``]}):`Finish review${i>0?` (${i})`:``}`}),(0,S.jsx)(Va,{label:`Settings`,triggerClassName:`btn btn-ghost btn-icon`,children:e=>(0,S.jsxs)(S.Fragment,{children:[p&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(Wa,{children:`Theme`}),(0,S.jsx)(Ha,{icon:`display`,checked:f===`system`,onClick:()=>{e(),p(`system`)},children:`System`}),(0,S.jsx)(Ha,{icon:`sun`,checked:f===`light`,onClick:()=>{e(),p(`light`)},children:`Light`}),(0,S.jsx)(Ha,{icon:`moon`,checked:f===`dark`,onClick:()=>{e(),p(`dark`)},children:`Dark`})]}),h&&(0,S.jsxs)(S.Fragment,{children:[p&&(0,S.jsx)(Ua,{}),(0,S.jsx)(Ha,{icon:`sparkle`,checked:m,onClick:()=>{e(),h(!m)},children:`Animations`})]}),g&&(0,S.jsxs)(S.Fragment,{children:[(p||h)&&(0,S.jsx)(Ua,{}),(0,S.jsx)(Ha,{icon:`keys`,kbd:`?`,onClick:()=>{e(),g()},children:`Shortcuts`})]}),_&&(0,S.jsxs)(S.Fragment,{children:[(p||h||g)&&(0,S.jsx)(Ua,{}),(0,S.jsx)(Ha,{icon:`lock`,onClick:()=>{e(),_()},children:`Privacy`})]})]})})]})}function lo({presence:e,reason:t,onClose:n}){let{data:r,isLoading:i,error:a}=bt(!0),[o,s]=(0,x.useState)(!1),[c,l]=(0,x.useState)(!1),[u,d]=(0,x.useState)(!1),f=e!==`waiting`,[p,m]=(0,x.useState)(f?`connected`:`invite`),[h,g]=(0,x.useState)(!1),_=(0,x.useRef)(f);(0,x.useEffect)(()=>{f!==_.current&&(_.current=f,m(f?`connected`:`invite`),g(!f))},[f]);let v=(0,x.useRef)(n);v.current=n,(0,x.useEffect)(()=>{if(p!==`connected`)return;let e=setTimeout(()=>v.current(),1800);return()=>clearTimeout(e)},[p]);let y=e=>{Ct(e).then(e=>{l(!e),e&&(s(!0),d(!0),setTimeout(()=>s(!1),2500))})};return p===`connected`?(0,S.jsx)(At,{title:`Agent attached`,onClose:n,children:(0,S.jsxs)(`div`,{className:`invite-connected`,children:[(0,S.jsx)(`span`,{className:`presence-dot`}),(0,S.jsx)(`p`,{className:`cov-note`,children:`Everything you send from here lands in that thread.`})]})}):(0,S.jsxs)(At,{title:`Connect your agent`,onClose:n,children:[h&&(0,S.jsxs)(`div`,{className:`warn`,children:[(0,S.jsx)(U,{name:`alert`,size:`sm`}),(0,S.jsx)(`div`,{children:t===`ended`?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`b`,{children:`Your agent left the review`}),`: it detached on purpose. Bring it back whenever you like.`]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`b`,{children:`Your agent disconnected`}),`: its poll died without detaching.`]})})]}),i&&(0,S.jsx)(`div`,{className:`shimmer`}),a&&(0,S.jsxs)(`p`,{className:`cov-note`,children:[`Couldn't build the invite: `,a.message]}),r&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`p`,{className:`cov-note`,children:`Paste this to your agent. Its Diffo skill does the rest.`}),(0,S.jsxs)(`button`,{type:`button`,className:`invite-cmd`,title:o?`Copied`:`copy the ask`,onClick:()=>y(r.ask),children:[(0,S.jsx)(`code`,{children:r.ask}),(0,S.jsx)(U,{name:o?`check`:`copy`,size:`sm`})]}),u&&(0,S.jsxs)(`div`,{className:`invite-live`,children:[(0,S.jsx)(`span`,{className:`presence-dot`}),`Listening for your agent…`]}),c&&(0,S.jsxs)(`div`,{className:`warn`,children:[(0,S.jsx)(U,{name:`alert`,size:`sm`}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`b`,{children:`Couldn't reach the clipboard`}),`: this browser blocked it. Select the text and copy it by hand.`]})]})]})]})}function uo(e){return e.hunks.length>0?e.hunks.map(e=>e.id):[fo(e)]}function fo(e){return`file:${e.status}:${e.oldPath??``}${e.path}`}function po(e,t){return t!==void 0&&uo(e).every(e=>t.has(e))}var mo=`Since your review`;function ho(e,t){return e.hunks.find(e=>e.lines.some(e=>e.kind!==`del`&&e.newNo===t))}function go(e,t){let n=t.get(e.path);if(!n)return{at:e};let r=e.line===void 0?void 0:ho(n,e.line);return r?{at:e,file:n,hunkId:r.id}:{at:e,file:n}}function _o(e,t){if(e&&e.length!==0)return e.map(e=>({decision:e,places:(e.at??[]).map(e=>go(e,t))}))}function vo(e,t){if(!e||e.items.length===0)return[];let n=new Map(t.map(e=>[e.path,e])),r=new Set,i=e.items.map((e,t)=>{let i=new Set,a=[],o=[];for(let t of e.files){let e=ut(t);if(i.has(e))continue;i.add(e),r.add(e);let s=n.get(e);if(!s){o.push(e);continue}let c=dt(t);a.push(c?{file:s,note:c}:{file:s})}let s=_o(e.decisions,n);return{id:e.id,number:t+1,title:e.title,...e.summary?{summary:e.summary}:{},...e.kind?{kind:e.kind}:{},files:a,missing:o,derived:!1,...s?{decisions:s}:{}}}),a=t.filter(e=>!r.has(e.path));return a.length>0&&i.push({id:null,number:null,title:mo,files:a.map(e=>({file:e})),missing:[],derived:!0}),i}function yo(e,t){return e.map(e=>{let n=e.files.filter(e=>!t(e.file)),r=e.files.length-n.length;return r===0?e:{...e,files:n,hidden:r}})}function bo(e){return e.id??`since`}function xo(e){return e.filter(e=>e.anchor.kind===`changeset`&&st(e)).at(-1)}function So(e){return e.find(e=>e.github?.kind===`description`)}function Co(e){let t=new Map;for(let n of e)for(let{file:e}of n.files)t.has(e.path)||t.set(e.path,n);return t}function wo(e,t){let n=0,r=0,i=0;for(let{file:a}of e.files){let e=uo(a),o=e.filter(e=>t.has(e)).length;n+=e.length,r+=o,o===e.length&&i++}return{files:e.files.length,doneFiles:i,marks:n,doneMarks:r}}function To(e){let t=0,n=0;for(let{file:r}of e.files)for(let e of r.hunks)for(let r of e.lines)r.kind===`add`?t++:r.kind===`del`&&n++;return{additions:t,deletions:n}}function Eo(e,t){let n=wo(e,t);return n.doneFiles===n.files}function Do(e,t,n,r=()=>!1){for(let i=t+n;i>=0&&i<e.length;i+=n)if(!r(e[i]))return i;return null}function Oo(e,t){let n=e.findIndex(e=>e.files.length>0&&!Eo(e,t));return n===-1?0:n}var ko=`#diffo-file:`;function Ao(e,t){return`${ko}${encodeURIComponent(e)}${t===null?``:`:${t}`}`}function jo(e){if(!e.startsWith(`#diffo-file:`))return null;let t=e.slice(12),n=/^(.*):(\d+)$/.exec(t);try{return n?{path:decodeURIComponent(n[1]),line:Number.parseInt(n[2],10)}:{path:decodeURIComponent(t),line:null}}catch{return null}}var Mo=/`([^`\n]+)`/g,No=/^([^\s:`]+?)(?::(\d+)(?:-\d+)?)?$/;function Po(e){let t=e.closest(`a[href], [data-diffo-jump]`);return t?jo(t.getAttribute(`data-diffo-jump`)??t.getAttribute(`href`)??``):null}function Y(e,t){if(t.includes(e))return e;let n=t.filter(t=>t.slice(t.lastIndexOf(`/`)+1)===e);return n.length===1?n[0]:null}function Fo(e,t){return t.length===0?e:e.split(/(```[\s\S]*?```|\[[^\]\n]*\]\([^)\n]*\))/).map((e,n)=>n%2==1?e:e.replace(Mo,(e,n)=>{let r=No.exec(n);if(!r)return e;let i=Y(r[1],t);return i===null?e:`[${e}](${Ao(i,r[2]===void 0?null:Number.parseInt(r[2],10))})`})).join(``)}function Io({state:e=!1}){return(0,S.jsx)(`span`,{className:`markbox`,"data-state":e===`mixed`?`mixed`:e?`on`:`off`,"aria-hidden":`true`,children:e===!0&&(0,S.jsx)(U,{name:`check`,size:`sm`})})}var Lo=()=>{let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`?!0:e===`light`?!1:window.matchMedia?.(`(prefers-color-scheme: dark)`).matches??!1};function Ro(){let[e,t]=(0,x.useState)(()=>typeof window<`u`&&Lo());return(0,x.useEffect)(()=>{let e=()=>t(Lo()),n=window.matchMedia?.(`(prefers-color-scheme: dark)`);n?.addEventListener(`change`,e);let r=new MutationObserver(e);return r.observe(document.documentElement,{attributeFilter:[`data-theme`]}),()=>{n?.removeEventListener(`change`,e),r.disconnect()}},[]),e}function zo(e){return`file-${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}`}function Bo(e,t,n=`start`){let r=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1,i=e.closest(`.reading-pane`),a=i?.scrollTop,o=()=>e.scrollIntoView({behavior:r?`instant`:`smooth`,block:n});if(o(),r){t?.(e);return}let s=i?.querySelector(`.reading-col`),c=e.offsetTop,l=null;s&&typeof ResizeObserver==`function`&&(l=new ResizeObserver(()=>{let t=e.offsetTop;t!==c&&(c=t,o())}),l.observe(s));let u=!1,d=()=>{u||(u=!0,l?.disconnect(),i&&i.scrollTop===a&&e.scrollIntoView({behavior:`instant`,block:n}),t?.(e))};i?.addEventListener(`scrollend`,d,{once:!0}),setTimeout(d,1200)}var Vo=[/[._-](test|spec)s?\.[^/]+$/,/(^|\/)test_[^/]+$/,/(^|[/.a-z0-9])Tests?\.[^/]+$/,/(^|\/)test[-_]?([Uu]tils?|[Hh]elpers?|[Ss]etup|[Ss]upport)\.[^/]+$/,/\.cy\.[^/]+$/,/[._-]e2e\.[^/]+$/,/(^|\/)(jest|vitest|playwright|cypress|karma|wdio|protractor)[.-](config|setup)(\.[^/]+)?$/,/\.snap$/,/[a-z0-9]Specs?\.(kt|kts|scala|groovy|swift)$/,/[a-z0-9](IT|ITCase)\.(java|kt|groovy|scala)$/,/(^|\/)(conftest|tests?)\.py$/,/(^|\/)pytest\.ini$/,/(^|\/)(spec|rails)_helper\.rb$/,/(^|\/)spec\/.+\.rb$/,/(^|\/)phpunit\.xml(\.dist)?$/,/(^|\/)mock_[^/]+\.go$/,/_mock\.go$/,/\.golden$/,/\.(feature|robot)$/,/(^|\/)(__tests__|__mocks__|__snapshots__|__fixtures__|[Tt]ests?)\//,/\.([A-Z][A-Za-z]*)?Tests?\//,/(^|\/)[a-z]+Tests?\//,/(^|\/)test[A-Z][A-Za-z]*\//,/(^|\/)tests?[-_][a-z]+\//,/(^|[/_-])e2e([-_][^/]*)?\//,/(^|\/)(cypress|playwright|testdata|step_definitions|mocks)\//];function Ho(e){return Vo.some(t=>t.test(e))}var Uo=`diffo:ui:hideReviewed`,Wo=`diffo:ui:hideTests`;function Go(e){let t=localStorage.getItem(e);return t===`1`||t!==`0`&&null}function Ko(e,t){let n=0,r=0,i=0,a=0,o=[];for(let s of e){let e=t.isDone(s);if(!t.pinned.has(s.path)){if(t.onlyChanged&&!t.changed.has(s.path)){e||(a++,o.push(s.path));continue}if(t.hideTests&&Ho(s.path)){e||(i++,o.push(s.path));continue}}r++,e||n++}return{left:n,total:r,excludedTests:i,excludedUnchanged:a,excludedPaths:o}}function qo(e,t){let n=[],r=t.query.trim().toLowerCase(),i=0,a=0,o=0,s=0;for(let c of e){if(t.pinned.has(c.path)){n.push(c);continue}if(r!==``&&!c.path.toLowerCase().includes(r)){s++;continue}if(t.onlyChanged&&!t.changed.has(c.path)){o++;continue}if(t.hideTests&&Ho(c.path)){i++;continue}if(t.hideReviewed&&t.isDone(c)){a++;continue}n.push(c)}return{visible:n,hiddenTests:i,hiddenReviewed:a,hiddenUnchanged:o,hiddenQuery:s}}function Jo(e,t,n){let[r,i]=(0,x.useState)(()=>Go(Uo)),[a,o]=(0,x.useState)(()=>Go(Wo)),[s,c]=(0,x.useState)(new Set),[l,u]=(0,x.useState)(``),d=(0,x.useCallback)(e=>{u(e),c(e=>e.size===0?e:new Set)},[]),f=r??e.length>25,p=a??!1,m=(0,x.useCallback)(e=>{localStorage.setItem(Uo,e?`1`:`0`),i(e),c(new Set)},[]),h=(0,x.useCallback)(e=>{localStorage.setItem(Wo,e?`1`:`0`),o(e)},[]),g=(0,x.useCallback)(e=>{c(t=>t.has(e)?t:new Set(t).add(e))},[]),_=(0,x.useCallback)(e=>{c(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),v=n.set,y=(0,x.useCallback)(()=>{localStorage.setItem(Uo,`0`),localStorage.setItem(Wo,`0`),i(!1),o(!1),c(new Set),u(``),v(!1)},[v]),b=(0,x.useMemo)(()=>qo(e,{query:l,hideReviewed:f,hideTests:p,onlyChanged:n.on,changed:n.changed,pinned:s,isDone:t}),[e,l,f,p,n.on,n.changed,s,t]),S=(0,x.useMemo)(()=>e.filter(e=>Ho(e.path)).length,[e]),C=(0,x.useMemo)(()=>Ko(e,{hideTests:p,onlyChanged:n.on,changed:n.changed,pinned:s,isDone:t}),[e,p,n.on,n.changed,s,t]);return{query:l,setQuery:d,hideReviewed:f,hideTests:p,setHideReviewed:m,setHideTests:h,onlyChanged:n.on,setOnlyChanged:v,files:b.visible,hiddenTests:b.hiddenTests,hiddenReviewed:b.hiddenReviewed,hiddenUnchanged:b.hiddenUnchanged,hiddenQuery:b.hiddenQuery,testCount:S,changedCount:n.changed.size,scope:C,pinned:s,pin:g,unpin:_,showAll:y}}var Yo=e=>e.slice(e.lastIndexOf(`/`)+1),Xo={added:`new file`,deleted:`deleted`,renamed:`renamed`,modified:`edited`};function Zo(e){let t={dirs:new Map,files:[],path:``};for(let n of e){let e=n.path.split(`/`),r=t;for(let t of e.slice(0,-1)){let e=r.dirs.get(t);e||(e={dirs:new Map,files:[],path:r.path===``?t:`${r.path}/${t}`},r.dirs.set(t,e)),r=e}r.files.push(n)}let n=e=>{let t=[];for(let[r,i]of e.dirs){let e={kind:`dir`,name:r,path:i.path,children:n(i)};for(;;){let t=e.children.length===1?e.children[0]:void 0;if(t===void 0||t.kind!==`dir`)break;e={kind:`dir`,name:`${e.name}/${t.name}`,path:t.path,children:t.children}}t.push(e)}t.sort((e,t)=>e.name.localeCompare(t.name));let r=e.files.map(e=>({kind:`file`,file:e})).sort((e,t)=>Yo(e.file.path).localeCompare(Yo(t.file.path)));return[...t,...r]};return n(t)}function Qo(e){return e.kind===`file`?[e.file]:e.children.flatMap(Qo)}function $o(e){return Zo(e).flatMap(Qo)}function es({file:e,depth:t,done:n,current:r,threads:i,wantsYou:a=0,changed:o=!1,note:s,onPick:c,onToggleViewed:l,onAsk:u}){let d=i?.length??0,f=0,p=0;for(let t of e.hunks)for(let e of t.lines)e.kind===`add`?f++:e.kind===`del`&&p++;let m=f>0||p>0?` · ${f>0?`+${f}`:``}${f>0&&p>0?` `:``}${p>0?`−${p}`:``}`:``;return(0,S.jsxs)(`div`,{className:`row${n?` row-done`:``}`,"aria-current":r?`true`:void 0,"data-path":e.path,style:{paddingLeft:12+t*14},children:[(0,S.jsx)(`button`,{type:`button`,className:`row-box`,role:`checkbox`,"aria-checked":n,"aria-label":`${n?`Mark not reviewed`:`Mark reviewed`}: ${e.path}`,"data-tip":n?`Mark not reviewed`:`Mark reviewed`,disabled:!l,onClick:l,children:(0,S.jsx)(Io,{state:n})}),(0,S.jsx)(`button`,{type:`button`,className:`row-pick`,title:`${e.path} · ${Xo[e.status]}${n?` · read`:``}${m}${s?`, ${s}`:``}`,onClick:()=>{if(c)return c();let t=document.getElementById(zo(e.path));t&&Bo(t)},children:(0,S.jsxs)(`span`,{className:`row-name`,children:[e.status===`added`&&(0,S.jsx)(`span`,{className:`row-st row-st-add`,"aria-hidden":`true`,children:`+`}),e.status===`deleted`&&(0,S.jsx)(`span`,{className:`row-st row-st-del`,"aria-hidden":`true`,children:`−`}),e.status===`renamed`&&e.oldPath!==null&&(0,S.jsxs)(`span`,{className:`row-was`,children:[Yo(e.oldPath),` →`]}),(0,S.jsx)(`span`,{className:`row-base${e.status===`deleted`?` row-base-del`:``}`,children:Yo(e.path)})]})}),(0,S.jsxs)(`span`,{className:`row-right`,children:[o&&(0,S.jsx)(`span`,{role:`img`,className:`row-since row-since-changed`,title:`your agent rewrote this since you last finished a review`,"aria-label":`changed since your last review`}),(0,S.jsx)(`span`,{className:`row-passive`,children:a>0?(0,S.jsxs)(`span`,{className:`row-count row-count-hot`,title:`${a} of ${d} thread${d===1?``:`s`} needs you`,children:[(0,S.jsx)(U,{name:`chat`,size:`sm`}),a,` needs you`]}):d>0?(0,S.jsxs)(`span`,{className:`row-count`,title:`${d} thread${d===1?``:`s`}`,children:[(0,S.jsx)(U,{name:`chat`,size:`sm`}),d]}):null}),(0,S.jsx)(`span`,{className:`row-acts`,children:u&&(0,S.jsx)(`button`,{type:`button`,className:`row-act`,"data-tip":`Comment on this file`,"aria-label":`Comment on this file`,onClick:u,children:(0,S.jsx)(U,{name:`chat`,size:`sm`})})})]})]})}function ts({files:e,viewed:t,selectedPath:n,onPickFile:r,onToggleFileViewed:i,onMarkFiles:a,onClearFiles:o,onAskFile:s,threads:c,attention:l,changed:u,notes:d,forceOpen:f=!1}){let[p,m]=(0,x.useState)(new Set),h=(0,x.useCallback)(e=>po(e,t),[t]),g=(0,x.useMemo)(()=>Zo(e),[e]),_=(e,t)=>(0,S.jsx)(es,{file:e,depth:t,done:h(e),current:n===e.path,threads:c?.get(e.path),wantsYou:(l?.get(e.path)??[]).filter(e=>e.turn===`yours`).length,changed:u?.has(e.path)??!1,note:d?.get(e.path),onPick:r?()=>r(e.path):void 0,onToggleViewed:i?()=>i(e.path):void 0,onAsk:s?()=>s(e.path):void 0},e.path),v=(e,t)=>{let n=Qo(e),r=f||!p.has(e.path),i=n.filter(h).length,s=n.length>0&&i===n.length,c=n.filter(e=>!h(e)),l=(0,S.jsxs)(`div`,{className:`row row-dir${s?` row-done`:``}`,style:{paddingLeft:12+t*14},children:[(0,S.jsx)(`button`,{type:`button`,className:`row-box`,role:`checkbox`,"aria-checked":s?!0:i>0&&`mixed`,"aria-label":s?`Mark ${e.name} not reviewed`:`Mark ${c.length} file${c.length===1?``:`s`} in ${e.name} reviewed`,"data-tip":s?`Mark ${n.length} file${n.length===1?``:`s`} not reviewed`:`Mark ${c.length} file${c.length===1?``:`s`} reviewed`,disabled:s?!o:!a,onClick:()=>{s?o?.(n.map(e=>e.path)):a?.(c.map(e=>e.path))},children:(0,S.jsx)(Io,{state:s?!0:i>0&&`mixed`})}),(0,S.jsx)(`button`,{type:`button`,className:`row-pick`,title:e.path,"aria-expanded":r,onClick:()=>m(t=>{let n=new Set(t);return r?n.add(e.path):n.delete(e.path),n}),children:(0,S.jsxs)(`span`,{className:`row-name`,children:[(0,S.jsx)(`span`,{className:`chevron${r?``:` chevron-shut`}`,children:(0,S.jsx)(U,{name:`chev`,size:`sm`})}),(0,S.jsx)(`span`,{className:`dir-ico`,children:(0,S.jsx)(U,{name:`folder`,size:`sm`})}),(0,S.jsx)(`span`,{className:`row-base`,children:e.name})]})})]},`dir:${e.path}`);return r?[l,...y(e.children,t+1)]:[l]},y=(e,t)=>e.flatMap(e=>e.kind===`file`?[_(e.file,t)]:v(e,t));return(0,S.jsx)(S.Fragment,{children:y(g,0)})}function ns({files:e,viewed:t,selectedPath:n,onPickFile:r,onToggleFileViewed:i,onMarkFiles:a,onClearFiles:o,onAskFile:s,threads:c,attention:l,changed:u,query:d,onQuery:f,focusTick:p=0,hideReviewed:m=!1,onHideReviewed:h,hideTests:g=!1,onHideTests:_,onlyChanged:v=!1,onOnlyChanged:y}){let[b,C]=(0,x.useState)(``),w=d??b,T=f??C,E=(0,x.useRef)(null);(0,x.useEffect)(()=>{p>0&&E.current?.focus()},[p]);let D=(0,x.useCallback)(e=>po(e,t),[t]),O=(0,x.useMemo)(()=>{let t=w.trim().toLowerCase();return e.filter(e=>(t===``||e.path.toLowerCase().includes(t))&&!(m&&D(e))&&!(g&&Ho(e.path))&&!(v&&!(u?.has(e.path)??!1)))},[e,w,m,g,v,u,D]),k=w.trim()!==``,A=w.trim().toLowerCase(),j=e.filter(e=>A===``||e.path.toLowerCase().includes(A)).length-O.length,M=!!(h||_||y);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`rail-search`,children:(0,S.jsxs)(`span`,{className:`sb`,children:[(0,S.jsx)(U,{name:`search`,size:`sm`}),(0,S.jsx)(`input`,{ref:E,className:`nav-search`,type:`search`,placeholder:`Filter files`,"aria-label":`Filter files`,title:`Press / to jump here`,value:w,onChange:e=>T(e.target.value)}),w!==``&&(0,S.jsx)(`button`,{type:`button`,className:`sb-clear`,"data-tip":`Clear filter`,"aria-label":`Clear filter`,onClick:()=>{T(``),E.current?.focus()},children:(0,S.jsx)(U,{name:`x`,size:`sm`})})]})}),(0,S.jsxs)(`div`,{className:`rail-scroll`,children:[(0,S.jsx)(ts,{files:O,viewed:t,selectedPath:n,onPickFile:r,onToggleFileViewed:i,onMarkFiles:a,onClearFiles:o,onAskFile:s,threads:c,attention:l,changed:u,forceOpen:k}),O.length===0&&j===0&&(0,S.jsx)(`div`,{className:`rail-empty`,children:`no files match`})]}),j>0&&(0,S.jsxs)(`div`,{className:`rail-hidden`,children:[j,` `,j===1?`file`:`files`,` hidden by filters`,M&&(0,S.jsx)(`button`,{type:`button`,className:`rail-hidden-show`,onClick:()=>{m&&h?.(!1),g&&_?.(!1),v&&y?.(!1)},children:`show`})]})]})}var rs=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function is(e){if(e.files.length>0)return null;let t=e.hidden??0;return t>0?`${rs(t,`test`)} hidden`:e.missing.length===0?`nothing here now`:`${rs(e.missing.length,`listed file`)} not in the changeset`}function as({layer:e,viewed:t}){let n=is(e);if(n!==null)return(0,S.jsx)(`span`,{children:n});let r=e.hidden??0,i=wo(e,t),{additions:a,deletions:o}=To(e),s=i.doneFiles===i.files?` · read`:``,c=e.kind===`mechanical`?` · mechanical`:``,l=r>0?` · ${r} hidden`:``;return(0,S.jsxs)(`span`,{children:[rs(i.files,`file`),(a>0||o>0)&&(0,S.jsxs)(S.Fragment,{children:[` · `,a>0&&(0,S.jsxs)(`span`,{className:`stat-add`,children:[`+`,a]}),a>0&&o>0&&` `,o>0&&(0,S.jsxs)(`span`,{className:`stat-del`,children:[`−`,o]})]}),s,c,l]})}function os({layer:e,index:t,current:n,open:r,onToggleOpen:i,viewed:a,threadCount:o,onPick:s,onMarkFiles:c,onClearFiles:l}){let u=wo(e,a),d=u.files>0&&u.doneFiles===u.files,f=u.doneMarks>0,p=e.files.filter(e=>!po(e.file,a)).map(e=>e.file.path),m=e.files.map(e=>e.file.path);return(0,S.jsxs)(`div`,{className:`row row-layer${d?` row-done`:``}${e.derived?` row-layer-since`:``}`,"aria-current":n?`true`:void 0,"data-layer":e.id??`since`,onClick:()=>s(t),children:[(0,S.jsx)(`button`,{type:`button`,className:`row-box`,role:`checkbox`,"aria-checked":d?!0:f?`mixed`:!1,"aria-label":d?`Mark ${e.title} not reviewed`:`Mark ${rs(p.length,`file`)} in ${e.title} reviewed`,"data-tip":d?`Mark ${rs(m.length,`file`)} not reviewed`:`Mark ${rs(p.length,`file`)} reviewed`,disabled:m.length===0||(d?!l:!c),onClick:e=>{e.stopPropagation(),d?l?.(m):c?.(p)},children:(0,S.jsx)(Io,{state:d?!0:f?`mixed`:!1})}),(0,S.jsxs)(`button`,{type:`button`,className:`row-pick`,title:e.title,onClick:e=>{e.stopPropagation(),s(t)},children:[(0,S.jsx)(`span`,{className:`row-name`,children:(0,S.jsx)(`span`,{className:`row-base`,children:e.title})}),(0,S.jsxs)(`span`,{className:`ch-sub`,children:[u.doneMarks>0&&(0,S.jsx)(`span`,{className:`prog-track`,"aria-hidden":`true`,children:(0,S.jsx)(`i`,{style:{width:`${u.marks===0?0:Math.round(u.doneMarks/u.marks*100)}%`}})}),(0,S.jsx)(as,{layer:e,viewed:a})]})]}),(0,S.jsxs)(`span`,{className:`row-right`,children:[o>0&&(0,S.jsxs)(`span`,{className:`row-count`,title:rs(o,`thread`),children:[(0,S.jsx)(U,{name:`chat`,size:`sm`}),o]}),e.files.length>0&&(0,S.jsx)(`button`,{type:`button`,className:`row-act ch-fold chevron${r?``:` chevron-shut`}`,"aria-expanded":r,"aria-label":`${r?`Hide`:`Show`} the files in ${e.title}`,"data-tip":r?`Hide files`:`Show files`,onClick:e=>{e.stopPropagation(),i()},children:(0,S.jsx)(U,{name:`chev`,size:`sm`})})]})]})}function ss({layer:e,...t}){let n=(0,x.useMemo)(()=>e.files.map(e=>e.file),[e.files]),r=(0,x.useMemo)(()=>new Map(e.files.flatMap(e=>e.note?[[e.file.path,e.note]]:[])),[e.files]);return(0,S.jsx)(ts,{files:n,notes:r,...t})}function cs({layers:e,activeIndex:t,onPick:n,viewed:r,guide:i,description:a,overviewActive:o=!1,onOpenGuide:s,threads:c,attention:l,changed:u,selectedPath:d,onPickFile:f,onToggleFileViewed:p,onMarkFiles:m,onClearFiles:h,onAskFile:g,onRefresh:_,request:v=null}){let y=e=>e.files.reduce((e,t)=>e+(c?.get(t.file.path)?.length??0),0),[b,C]=(0,x.useState)(new Set),w=e=>b.has(e.id??`since`),T=e=>C(t=>{let n=new Set(t),r=e.id??`since`;return n.has(r)?n.delete(r):n.add(r),n});return(0,S.jsxs)(`div`,{className:`rail-scroll`,children:[(i||a)&&(0,S.jsxs)(`div`,{className:`row row-layer row-layer-overview`,"aria-current":o?`true`:void 0,onClick:s,children:[(0,S.jsx)(`span`,{className:`row-box`,"aria-hidden":`true`,children:(0,S.jsx)(Io,{})}),(0,S.jsxs)(`button`,{type:`button`,className:`row-pick`,title:a&&i?`The pull request description, and the agent’s guide to this change`:a?`The pull request description`:`The agent’s guide to this change`,onClick:e=>{e.stopPropagation(),s?.()},children:[(0,S.jsx)(`span`,{className:`row-name`,children:(0,S.jsx)(`span`,{className:`row-base`,children:`Overview`})}),(0,S.jsx)(`span`,{className:`ch-sub`,children:(0,S.jsx)(`span`,{children:a&&i?`the description, and the agent’s guide`:a?`the pull request description`:`the agent’s guide`})})]}),(0,S.jsx)(`span`,{className:`row-right`})]}),e.map((e,i)=>{let a=i===t,o=w(e);return(0,S.jsxs)(`div`,{className:`ch-layer`,children:[e.derived&&(0,S.jsx)(`div`,{className:`rail-rule`}),(0,S.jsx)(os,{layer:e,index:i,current:a,open:o,onToggleOpen:()=>T(e),viewed:r,threadCount:y(e),onPick:n,onMarkFiles:m,onClearFiles:h}),o&&e.files.length>0&&(0,S.jsx)(`div`,{className:`ch-files`,children:(0,S.jsx)(ss,{layer:e,viewed:r,selectedPath:d,threads:c,attention:l,changed:u,onPickFile:f,onToggleFileViewed:p,onMarkFiles:m,onClearFiles:h,onAskFile:g})})]},e.id??`since`)}),v===null?_?(0,S.jsx)(`button`,{type:`button`,className:`ch-foot ch-foot-act`,title:`the change moved on; a re-post keeps your place`,onClick:_,children:`Ask the agent to re-outline…`}):(0,S.jsx)(`div`,{className:`ch-foot`,title:`Invite one from the header`,children:`No agent attached to re-outline`}):(0,S.jsxs)(`div`,{className:`ch-foot ch-foot-live`,"aria-live":`polite`,children:[(0,S.jsxs)(`span`,{className:`ch-working`,"aria-hidden":`true`,children:[(0,S.jsx)(`i`,{}),(0,S.jsx)(`i`,{}),(0,S.jsx)(`i`,{})]}),` `,v===`outlining`?`re-outlining…`:`asked · waits for the open threads`]})]})}function ls({state:e,onOutline:t,onInvite:n}){if(e===`queued`||e===`outlining`){let t=e===`outlining`;return(0,S.jsx)(`div`,{className:`rail-scroll`,children:(0,S.jsxs)(`div`,{className:`ch-empty`,"data-state":e,"aria-live":`polite`,children:[(0,S.jsxs)(`h2`,{className:`ch-empty-title`,children:[(0,S.jsxs)(`span`,{className:`ch-working${t?``:` ch-working-idle`}`,"aria-hidden":`true`,children:[(0,S.jsx)(`i`,{}),(0,S.jsx)(`i`,{}),(0,S.jsx)(`i`,{})]}),t?`Outlining…`:`Asked`]}),(0,S.jsx)(`p`,{className:`ch-empty-sub`,children:t?`The steps appear here as soon as the agent posts them.`:`The agent starts once it finishes the threads it’s answering.`})]})})}return(0,S.jsx)(`div`,{className:`rail-scroll`,children:(0,S.jsxs)(`div`,{className:`ch-empty`,"data-state":e,"aria-live":`polite`,children:[(0,S.jsx)(`h2`,{className:`ch-empty-title`,children:`Read in layers`}),(0,S.jsx)(`p`,{className:`ch-empty-sub`,children:`The agent splits its change into steps you read in order.`}),e===`noagent`?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`p`,{className:`ch-empty-note`,children:`No agent is attached to outline it.`}),n&&(0,S.jsx)(`button`,{type:`button`,className:`btn ch-empty-cta`,onClick:n,children:`Invite an agent`})]}):(0,S.jsxs)(`button`,{type:`button`,className:`btn ch-empty-cta`,onClick:t,disabled:!t,children:[(0,S.jsx)(U,{name:`list`,size:`sm`}),`Ask the agent to outline`]})]})})}function us({tab:e,onSetTab:t,fileCount:n,threadCount:r,settledCount:i=0,wantsYou:a,layerCount:o=null,layersSuggested:s=!1,layers:c,files:l,threads:u}){return(0,S.jsxs)(`nav`,{className:`rail`,children:[(0,S.jsxs)(`div`,{className:`tabs`,role:`tablist`,"aria-label":`Files, threads, or layers`,children:[(0,S.jsxs)(`button`,{type:`button`,role:`tab`,className:`tab`,"aria-selected":e===`files`,onClick:()=>t(`files`),children:[`Files `,(0,S.jsx)(`span`,{className:`tab-n`,children:n})]}),(0,S.jsxs)(`button`,{type:`button`,role:`tab`,className:`tab`,"aria-selected":e===`threads`,onClick:()=>t(`threads`),title:i>0?`${r} still going · ${i} settled`:void 0,children:[a>0&&(0,S.jsx)(`span`,{className:`tab-dot`,"aria-hidden":`true`}),`Threads `,(0,S.jsx)(`span`,{className:`tab-n`,children:r})]}),(0,S.jsxs)(`button`,{type:`button`,role:`tab`,className:`tab`,"aria-selected":e===`layers`,onClick:()=>t(`layers`),title:o===null?`The agent’s reading plan, once it posts one`:void 0,children:[s&&o===null&&(0,S.jsx)(`span`,{className:`tab-dot`,"aria-hidden":`true`}),`Layers `,o!==null&&(0,S.jsx)(`span`,{className:`tab-n`,children:o})]})]}),e===`layers`?c:e===`files`?l:u]})}var ds=(0,x.createContext)(null);function fs(){return(0,x.useContext)(ds)}function ps(e){return e.state===`resolved`?`resolved`:it(e)?e.state===`open`&&!e.github?`note`:`posted`:lt(e)&&e.state===`open`?`proposed`:e.state===`open`?`note`:e.messages.at(-1)?.author===`agent`?e.awaitingFollowUp===!0?`agent`:`yours`:e.withheld?`note`:e.unanswered?e.state===`addressed`?`yours`:`unanswered`:`agent`}function ms(e){return(e.state===`open`||e.withheld===!0)&&!lt(e)&&!it(e)}var hs=[`yours`,`unanswered`,`proposed`,`agent`,`note`,`posted`,`resolved`],gs={yours:`Your turn`,unanswered:`No answer`,proposed:`From the agent`,agent:`Waiting on agent`,note:`Draft`,posted:`On GitHub`,resolved:`Resolved`},_s=[`yours`,`proposed`,`agent`,`note`,`posted`,`settled`],vs={yours:`Your turn`,proposed:`From the agent`,agent:`Waiting on the agent`,note:`Drafts`,posted:`On GitHub`,settled:`Settled`};function ys(e){switch(e){case`yours`:case`unanswered`:return`yours`;case`proposed`:return`proposed`;case`agent`:return`agent`;case`note`:return`note`;case`posted`:return`posted`;case`resolved`:return`settled`}}function bs(e){if(e.state===`open`||e.state===`resolved`||it(e))return null;let t=e.messages.at(-1)?.author===`agent`&&e.awaitingFollowUp!==!0,n=e.state===`addressed`;return t?n?`fixed`:`answered`:n?`changed`:e.unanswered?`no-answer`:`waiting`}function xs(e){for(let t of e.split(`
80
80
  `)){let e=t.trim();if(e!==``)return e}return``}function Ss(e){let t=e.anchor;return t.kind===`changeset`?{anchor:null,path:null}:t.kind===`file`?{anchor:t.path,path:t.path}:t.kind===`layer`?{anchor:`layer “${t.title}”`,path:null}:{anchor:`${t.path}:${pt(t)}`,path:t.path}}function Cs(e,t){if(e.messages.some(e=>e.author===`reviewer`))return!0;if(!t)return!1;let n=RegExp(`@${t}(?![\\w-])`,`i`);return e.messages.some(e=>e.author===`github`&&(e.github?.user.login===t||n.test(e.text)))}function ws(e){let t=e=>hs.indexOf(e.turn),n=e=>e.sort((e,n)=>t(e)-t(n)||n.updatedAt.localeCompare(e.updatedAt));return{github:n(e.filter(e=>it(e.thread))),agent:n(e.filter(e=>!it(e.thread)))}}function Ts(e,t=new Set,n=new Map){return e.map(e=>{let r=[...e.messages].reverse().find(t=>it(e)?t.author===`github`:t.author===`agent`),i=n.get(e.id),a=bs(e);return{thread:e,turn:ps(e),...a?{outcome:a}:{},...t.has(e.id)?{working:!0}:{},...i!==void 0&&!t.has(e.id)?{queued:i}:{},...e.github?.outdated===!0?{outdated:!0}:{},question:xs(e.messages[0]?.text??``),answer:r?xs(r.text):null,...Ss(e),...r?.durationMs===void 0?{}:{durationMs:r.durationMs},updatedAt:e.updatedAt}})}function Es(e){return e===null?`the changeset`:e.slice(e.lastIndexOf(`/`)+1)}function Ds(e,t){let n=e.find(e=>e.working===!0);return n?`working on ${Es(n.anchor)}`:t===null?e.length>0?`picked up ${e.length} comment${e.length===1?``:`s`}`:null:`answered ${t}`}function Os(e){let t=new Map;for(let n of _s){let r=e.filter(e=>ys(e.turn)===n).sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt));r.length>0&&t.set(n,r)}return t}function ks(e){return e.filter(e=>e.turn===`yours`||e.turn===`unanswered`).length}function As(e){return e.filter(e=>ys(e.turn)!==`settled`).length}function js(e){let t=new Map;for(let n of e){if(n.path===null)continue;let e=t.get(n.path);e?e.push(n):t.set(n.path,[n])}return t}var Ms=`modulepreload`,Ns=function(e){return`/`+e},Ps={},Fs=function(e){return e.pathname.endsWith(`.css`)},X=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=Ns(t,n);let r=s(t);if(r.href in Ps)return;Ps[r.href]=!0;let i=Fs(r);if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let o=document.createElement(`link`);if(o.rel=i?`stylesheet`:Ms,i||(o.as=`script`),o.crossOrigin=``,o.href=r.href,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),i)return new Promise((e,t)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>t(Error(`Unable to preload CSS for ${r}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Is=null,Ls=null,Rs=null,zs=0,Bs=fr(),Vs=/^(graph|flowchart|stateDiagram|sequenceDiagram|classDiagram|erDiagram|xychart)\b/;function Hs(e){for(let t of e.split(`
81
- `)){let e=t.trim();if(!(e===``||e.startsWith(`%%`)))return Vs.test(e)}return!1}var Us={bg:`var(--fill)`,fg:`var(--ink)`,transparent:!0,font:`system-ui`};function Ws(e){return e.replace(/@import url\([^)]*\);?/g,``)}async function Gs(){return Is||=X(()=>import(`./dist-Cr2gbd4l.js`),[]),Is}function Ks(){let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`?`dark`:e===`light`?`neutral`:window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`neutral`}async function qs(){Ls||=X(()=>import(`./mermaid.core-DP4c5AXa.js`).then(e=>e.default),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]));let e=await Ls,t=Ks();return Rs!==t&&(Rs=t,e.initialize({startOnLoad:!1,securityLevel:`strict`,theme:t,htmlLabels:!1,flowchart:{htmlLabels:!1,useMaxWidth:!1},sequence:{useMaxWidth:!1},state:{useMaxWidth:!1},er:{useMaxWidth:!1},class:{useMaxWidth:!1},pie:{useMaxWidth:!1}})),e}async function Js(e){try{let t=await qs();await t.parse(e);let{svg:n}=await t.render(`diffo-mermaid-${++zs}`,e);return n}catch{return null}}async function Ys(e){if(Hs(e))try{return{svg:Ws((await Gs()).renderMermaidSVG(e,Us)),live:!0}}catch{}let t=await Js(e);return t===null?null:{svg:t,live:!1}}function Xs(e){return Bs.sanitize(e,{USE_PROFILES:{svg:!0,svgFilters:!0}})}var Zs=.6;function Qs(e){let t=e.querySelector(`svg`);if(!t)return;let n=Number.parseFloat(t.getAttribute(`width`)??``)||Number.parseFloat(t.getAttribute(`viewBox`)?.split(/\s+/)[2]??``);Number.isFinite(n)&&n>0&&(t.style.minWidth=`${Math.round(n*Zs)}px`)}var $s=[29,29,31],ec=[245,245,247];function tc(e){let t=e.trim().toLowerCase(),n=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.exec(t)?.[1];if(n){let[e,t,r,i]=(n.length<=4?Array.from(n,e=>e+e):n.match(/../g)).map(e=>Number.parseInt(e,16));return{rgb:[e,t,r],alpha:i===void 0?1:i/255}}let r=/^rgba?\(([^)]*)\)$/.exec(t)?.[1];if(r){let e=r.split(/[\s,/]+/).filter(Boolean);if(e.length<3)return null;let[t,n,i]=e.slice(0,3).map(Number),a=e[3]===void 0?1:Number.parseFloat(e[3])/(e[3].endsWith(`%`)?100:1);return[t,n,i,a].every(Number.isFinite)?{rgb:[t,n,i],alpha:a}:null}return null}function nc(e){let[t,n,r]=e.map(e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return .2126*t+.7152*n+.0722*r}function rc(e){for(let t of Array.from(e.querySelectorAll(`g.node`))){let e=t.querySelectorAll(`text[fill="var(--_text)"]`),n=t.querySelector(`[fill]:not(text):not(tspan)`),r=n?.getAttribute(`fill`)??``;if(e.length===0||!n||r.startsWith(`var(`)||r===`none`)continue;let i=tc(r)??tc(getComputedStyle(n).fill);if(!i||i.alpha<.5)continue;let a=nc(i.rgb),o=(a+.05)/(nc($s)+.05)>=(nc(ec)+.05)/(a+.05)?$s:ec;for(let t of Array.from(e))t.setAttribute(`fill`,`rgb(${o.join(` `)})`)}}var ic=!1;function ac(){if(ic)return;ic=!0;let e=()=>void oc();new MutationObserver(e).observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]}),window.matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,e)}async function oc(){if(Ks()===Rs)return;let e=document.querySelectorAll(`.mermaid-figure[data-mermaid-source]`);for(let t of Array.from(e)){let e=await Js(t.dataset.mermaidSource??``);e!==null&&t.isConnected&&(t.innerHTML=Xs(e),Qs(t))}}function sc(e){return Array.from(e.querySelectorAll(`code.language-mermaid`)).map(e=>e.closest(`pre`)).filter(e=>e!==null&&!e.hasAttribute(`data-mermaid-done`))}async function cc(e){if(e&&sc(e).length!==0)for(let t of sc(e)){if(t.hasAttribute(`data-mermaid-done`))continue;t.setAttribute(`data-mermaid-done`,``);let e=t.textContent??``,n=await Ys(e);if(!t.isConnected)continue;if(n===null){let e=document.createElement(`div`);e.className=`mermaid-broken`,e.textContent=`diagram didn't parse, showing its source`,t.before(e);continue}let r=document.createElement(`div`);r.className=`mermaid-figure`,r.innerHTML=Xs(n.svg),Qs(r),n.live||(r.dataset.mermaidSource=e,ac()),t.replaceWith(r),n.live&&rc(r)}}function lc(e){let t=Array.from(e.querySelectorAll(`tspan`));return t.length===0?e.textContent??``:t.map(e=>e.textContent??``).join(` `)}function uc(e){return e.split(/[\s·,;()[\]{}"'«»]+/).filter(Boolean)}function dc(e,t){for(let n of uc(e)){let e=No.exec(n);if(!e)continue;let r=Y(e[1],t);if(r!==null)return{path:r,line:e[2]===void 0?null:Number.parseInt(e[2],10)}}return null}function fc(e,t){if(!e||t.length===0)return;let n=e.querySelectorAll(`.mermaid-figure text:not([data-diffo-jump]):not([data-diffo-plain])`);for(let e of Array.from(n)){let n=dc(lc(e),t);if(!n){e.setAttribute(`data-diffo-plain`,``);continue}e.setAttribute(`data-diffo-jump`,Ao(n.path,n.line)),e.setAttribute(`role`,`link`),e.setAttribute(`tabindex`,`0`),e.classList.add(`diffo-ref`)}}var pc=(0,x.memo)(function({text:e,className:t,docPath:n,paths:r}){let i=(0,x.useRef)(null),a=n===void 0?oa(e):ga(e,n);return(0,x.useEffect)(()=>{let e=i.current;if(!e)return;let t=async()=>{await cc(e),r&&fc(e,r)};t();let n=new MutationObserver(()=>{t()});return n.observe(e,{childList:!0,subtree:!0}),()=>n.disconnect()},[a,r]),(0,S.jsx)(`div`,{ref:i,className:t,dangerouslySetInnerHTML:{__html:a}})});function mc({who:e,user:t}){return e===`github`?t?.avatarUrl?(0,S.jsx)(`img`,{className:`avatar avatar-github`,src:t.avatarUrl,alt:``,"aria-hidden":`true`}):(0,S.jsx)(`span`,{className:`avatar avatar-github`,"aria-hidden":`true`,children:(t?.login??`?`).slice(0,1).toUpperCase()}):(0,S.jsx)(`span`,{className:`avatar avatar-${e}`,"aria-hidden":`true`,children:(0,S.jsx)(U,{name:e===`you`?`user`:`sparkle`,size:`sm`})})}function hc({value:e,onChange:t}){return(0,S.jsxs)(`div`,{className:`aud-tabs`,role:`radiogroup`,"aria-label":`Who this comment is for`,children:[(0,S.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":e===`pr`,className:`aud-tab aud-tab-pr${e===`pr`?` aud-tab-on`:``}`,title:`a review comment: drafted here, posted to GitHub when you submit (⌘. flips)`,onClick:()=>t(`pr`),children:[(0,S.jsx)(U,{name:`globe`,size:`sm`}),` Comment on PR`]}),(0,S.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":e===`agent`,className:`aud-tab aud-tab-agent${e===`agent`?` aud-tab-on`:``}`,title:`a private question for your agent: never leaves this machine (⌘. flips)`,onClick:()=>t(`agent`),children:[(0,S.jsx)(U,{name:`lock`,size:`sm`}),` Ask agent`]})]})}var gc=[{icon:`bold`,label:`Bold`,wrap:[`**`,`**`]},{icon:`italic`,label:`Italic`,wrap:[`_`,`_`]},{icon:`code`,label:`Code`,wrap:["`","`"]},`sep`,{icon:`link`,label:`Link`,wrap:[`[`,`](url)`]},{icon:`list`,label:`Bulleted list`,prefix:`- `},{icon:`quote`,label:`Quote`,prefix:`> `},`sep`,{icon:`at`,label:`Reference a file`,wrap:["`","`"]}],_c=[{label:`Explain this`,text:`Explain what this does and why it’s needed.`,intent:`question`},{label:`Clean up the comments`,text:`Cut comments that narrate the code. Keep the ones that explain why.`,intent:`fix`},{label:`Simplify this`,text:`Simplify this. Same behavior, less code, no new abstractions.`,intent:`fix`}],vc=[{intent:`fix`,label:`Change`,title:`ask the agent to change the code`},{intent:`question`,label:`Question`,title:`ask for an answer; the agent won’t change code`},{intent:void 0,label:`Agent decides`,title:`no label — the agent reads what you want from your words`}];function yc(e,t,n){let{value:r,selectionStart:i,selectionEnd:a}=e,o=r.slice(i,a),s,c;if(t.prefix){let e=r.lastIndexOf(`
81
+ `)){let e=t.trim();if(!(e===``||e.startsWith(`%%`)))return Vs.test(e)}return!1}var Us={bg:`var(--fill)`,fg:`var(--ink)`,transparent:!0,font:`system-ui`};function Ws(e){return e.replace(/@import url\([^)]*\);?/g,``)}async function Gs(){return Is||=X(()=>import(`./dist-B77Lw20A.js`),[]),Is}function Ks(){let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`?`dark`:e===`light`?`neutral`:window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`neutral`}async function qs(){Ls||=X(()=>import(`./mermaid.core-P7Zn0OkI.js`).then(e=>e.default),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]));let e=await Ls,t=Ks();return Rs!==t&&(Rs=t,e.initialize({startOnLoad:!1,securityLevel:`strict`,theme:t,htmlLabels:!1,flowchart:{htmlLabels:!1,useMaxWidth:!1},sequence:{useMaxWidth:!1},state:{useMaxWidth:!1},er:{useMaxWidth:!1},class:{useMaxWidth:!1},pie:{useMaxWidth:!1}})),e}async function Js(e){try{let t=await qs();await t.parse(e);let{svg:n}=await t.render(`diffo-mermaid-${++zs}`,e);return n}catch{return null}}async function Ys(e){if(Hs(e))try{return{svg:Ws((await Gs()).renderMermaidSVG(e,Us)),live:!0}}catch{}let t=await Js(e);return t===null?null:{svg:t,live:!1}}function Xs(e){return Bs.sanitize(e,{USE_PROFILES:{svg:!0,svgFilters:!0}})}var Zs=.6;function Qs(e){let t=e.querySelector(`svg`);if(!t)return;let n=Number.parseFloat(t.getAttribute(`width`)??``)||Number.parseFloat(t.getAttribute(`viewBox`)?.split(/\s+/)[2]??``);Number.isFinite(n)&&n>0&&(t.style.minWidth=`${Math.round(n*Zs)}px`)}var $s=[29,29,31],ec=[245,245,247];function tc(e){let t=e.trim().toLowerCase(),n=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.exec(t)?.[1];if(n){let[e,t,r,i]=(n.length<=4?Array.from(n,e=>e+e):n.match(/../g)).map(e=>Number.parseInt(e,16));return{rgb:[e,t,r],alpha:i===void 0?1:i/255}}let r=/^rgba?\(([^)]*)\)$/.exec(t)?.[1];if(r){let e=r.split(/[\s,/]+/).filter(Boolean);if(e.length<3)return null;let[t,n,i]=e.slice(0,3).map(Number),a=e[3]===void 0?1:Number.parseFloat(e[3])/(e[3].endsWith(`%`)?100:1);return[t,n,i,a].every(Number.isFinite)?{rgb:[t,n,i],alpha:a}:null}return null}function nc(e){let[t,n,r]=e.map(e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return .2126*t+.7152*n+.0722*r}function rc(e){for(let t of Array.from(e.querySelectorAll(`g.node`))){let e=t.querySelectorAll(`text[fill="var(--_text)"]`),n=t.querySelector(`[fill]:not(text):not(tspan)`),r=n?.getAttribute(`fill`)??``;if(e.length===0||!n||r.startsWith(`var(`)||r===`none`)continue;let i=tc(r)??tc(getComputedStyle(n).fill);if(!i||i.alpha<.5)continue;let a=nc(i.rgb),o=(a+.05)/(nc($s)+.05)>=(nc(ec)+.05)/(a+.05)?$s:ec;for(let t of Array.from(e))t.setAttribute(`fill`,`rgb(${o.join(` `)})`)}}var ic=!1;function ac(){if(ic)return;ic=!0;let e=()=>void oc();new MutationObserver(e).observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]}),window.matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,e)}async function oc(){if(Ks()===Rs)return;let e=document.querySelectorAll(`.mermaid-figure[data-mermaid-source]`);for(let t of Array.from(e)){let e=await Js(t.dataset.mermaidSource??``);e!==null&&t.isConnected&&(t.innerHTML=Xs(e),Qs(t))}}function sc(e){return Array.from(e.querySelectorAll(`code.language-mermaid`)).map(e=>e.closest(`pre`)).filter(e=>e!==null&&!e.hasAttribute(`data-mermaid-done`))}async function cc(e){if(e&&sc(e).length!==0)for(let t of sc(e)){if(t.hasAttribute(`data-mermaid-done`))continue;t.setAttribute(`data-mermaid-done`,``);let e=t.textContent??``,n=await Ys(e);if(!t.isConnected)continue;if(n===null){let e=document.createElement(`div`);e.className=`mermaid-broken`,e.textContent=`diagram didn't parse, showing its source`,t.before(e);continue}let r=document.createElement(`div`);r.className=`mermaid-figure`,r.innerHTML=Xs(n.svg),Qs(r),n.live||(r.dataset.mermaidSource=e,ac()),t.replaceWith(r),n.live&&rc(r)}}function lc(e){let t=Array.from(e.querySelectorAll(`tspan`));return t.length===0?e.textContent??``:t.map(e=>e.textContent??``).join(` `)}function uc(e){return e.split(/[\s·,;()[\]{}"'«»]+/).filter(Boolean)}function dc(e,t){for(let n of uc(e)){let e=No.exec(n);if(!e)continue;let r=Y(e[1],t);if(r!==null)return{path:r,line:e[2]===void 0?null:Number.parseInt(e[2],10)}}return null}function fc(e,t){if(!e||t.length===0)return;let n=e.querySelectorAll(`.mermaid-figure text:not([data-diffo-jump]):not([data-diffo-plain])`);for(let e of Array.from(n)){let n=dc(lc(e),t);if(!n){e.setAttribute(`data-diffo-plain`,``);continue}e.setAttribute(`data-diffo-jump`,Ao(n.path,n.line)),e.setAttribute(`role`,`link`),e.setAttribute(`tabindex`,`0`),e.classList.add(`diffo-ref`)}}var pc=(0,x.memo)(function({text:e,className:t,docPath:n,paths:r}){let i=(0,x.useRef)(null),a=n===void 0?oa(e):ga(e,n);return(0,x.useEffect)(()=>{let e=i.current;if(!e)return;let t=async()=>{await cc(e),r&&fc(e,r)};t();let n=new MutationObserver(()=>{t()});return n.observe(e,{childList:!0,subtree:!0}),()=>n.disconnect()},[a,r]),(0,S.jsx)(`div`,{ref:i,className:t,dangerouslySetInnerHTML:{__html:a}})});function mc({who:e,user:t}){return e===`github`?t?.avatarUrl?(0,S.jsx)(`img`,{className:`avatar avatar-github`,src:t.avatarUrl,alt:``,"aria-hidden":`true`}):(0,S.jsx)(`span`,{className:`avatar avatar-github`,"aria-hidden":`true`,children:(t?.login??`?`).slice(0,1).toUpperCase()}):(0,S.jsx)(`span`,{className:`avatar avatar-${e}`,"aria-hidden":`true`,children:(0,S.jsx)(U,{name:e===`you`?`user`:`sparkle`,size:`sm`})})}function hc({value:e,onChange:t}){return(0,S.jsxs)(`div`,{className:`aud-tabs`,role:`radiogroup`,"aria-label":`Who this comment is for`,children:[(0,S.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":e===`pr`,className:`aud-tab aud-tab-pr${e===`pr`?` aud-tab-on`:``}`,title:`a review comment: drafted here, posted to GitHub when you submit (⌘. flips)`,onClick:()=>t(`pr`),children:[(0,S.jsx)(U,{name:`globe`,size:`sm`}),` Comment on PR`]}),(0,S.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":e===`agent`,className:`aud-tab aud-tab-agent${e===`agent`?` aud-tab-on`:``}`,title:`a private question for your agent: never leaves this machine (⌘. flips)`,onClick:()=>t(`agent`),children:[(0,S.jsx)(U,{name:`lock`,size:`sm`}),` Ask agent`]})]})}var gc=[{icon:`bold`,label:`Bold`,wrap:[`**`,`**`]},{icon:`italic`,label:`Italic`,wrap:[`_`,`_`]},{icon:`code`,label:`Code`,wrap:["`","`"]},`sep`,{icon:`link`,label:`Link`,wrap:[`[`,`](url)`]},{icon:`list`,label:`Bulleted list`,prefix:`- `},{icon:`quote`,label:`Quote`,prefix:`> `},`sep`,{icon:`at`,label:`Reference a file`,wrap:["`","`"]}],_c=[{label:`Explain this`,text:`Explain what this does and why it’s needed.`,intent:`question`},{label:`Clean up the comments`,text:`Cut comments that narrate the code. Keep the ones that explain why.`,intent:`fix`},{label:`Simplify this`,text:`Simplify this. Same behavior, less code, no new abstractions.`,intent:`fix`}],vc=[{intent:`fix`,label:`Change`,title:`ask the agent to change the code`},{intent:`question`,label:`Question`,title:`ask for an answer; the agent won’t change code`},{intent:void 0,label:`Agent decides`,title:`no label — the agent reads what you want from your words`}];function yc(e,t,n){let{value:r,selectionStart:i,selectionEnd:a}=e,o=r.slice(i,a),s,c;if(t.prefix){let e=r.lastIndexOf(`
82
82
  `,i-1)+1,n=r.indexOf(`
83
83
  `,a),o=n===-1?r.length:n,l=r.slice(e,o).split(`
84
84
  `).map(e=>`${t.prefix}${e}`).join(`
85
85
  `);s=r.slice(0,e)+l+r.slice(o),c=[e,e+l.length]}else{let[e,n]=t.wrap;s=r.slice(0,i)+e+o+n+r.slice(a),c=o?[i+e.length,i+e.length+o.length]:[i+e.length,i+e.length]}n(s),requestAnimationFrame(()=>{e.focus(),e.setSelectionRange(c[0],c[1])})}function bc({title:e,placeholder:t,scope:n,onSubmit:r,onSend:i,onCancel:a,agentConnected:o=!1,autoFocus:s=!0,draft:c,onDraft:l,draftIntent:u,onDraftIntent:d,initialText:f,fixedAudience:p,citing:m}){let[h,g]=(0,x.useState)(f??``),[_,v]=(0,x.useState)(`write`),[y,b]=(0,x.useState)(!1),C=fs(),[w,T]=(0,x.useState)(`pr`),E=C===null?void 0:p??w,D=E===`pr`,O=E!==void 0&&p===void 0,k=E===`agent`&&i!==void 0,[A,j]=(0,x.useState)(void 0),[M,N]=(0,x.useState)(!1),P=l?c??``:h,F=l??g,I=d?u:A,ee=d??j,te=(0,x.useRef)(null),ne=P.trim().length>0,L=e=>m?`> ${m.label}: ${m.text}\n\n${e}`:e,re=()=>{ne&&(E===void 0?r(L(P),y,I):k?i(L(P),y,void 0):r(L(P),y,void 0,E))},ie=()=>T(e=>e===`pr`?`agent`:`pr`),ae=()=>{N(e=>!e),v(`write`)},oe=(0,S.jsx)(S.Fragment,{children:n&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`span`,{className:`scope-chip`,children:[(0,S.jsx)(U,{name:y?`cmp`:`unified`,size:`sm`}),y?`the whole changeset`:n.label,!y&&n.adjust&&(0,S.jsxs)(`span`,{className:`scope-chip-steppers`,children:[(0,S.jsx)(`button`,{type:`button`,className:`scope-chip-step`,disabled:!n.adjust.up,"data-tip":`walk the range's edge one line up; the line you started on stays put`,"aria-label":`range edge one line up`,onClick:n.adjust.up,children:(0,S.jsx)(U,{name:`up`,size:`sm`})}),(0,S.jsx)(`button`,{type:`button`,className:`scope-chip-step`,disabled:!n.adjust.down,"data-tip":`walk the range's edge one line down; the line you started on stays put`,"aria-label":`range edge one line down`,onClick:n.adjust.down,children:(0,S.jsx)(U,{name:`down`,size:`sm`})})]}),y&&n.canWiden&&(0,S.jsx)(`button`,{type:`button`,className:`scope-chip-x`,"data-tip":`Narrow the scope back`,"aria-label":`Narrow the scope back`,onClick:()=>b(!1),children:(0,S.jsx)(U,{name:`x`,size:`sm`})})]}),!y&&n.canWiden&&(0,S.jsx)(`button`,{type:`button`,className:`cbox-widen`,onClick:()=>b(!0),children:`+ whole changeset`})]})}),se=(0,S.jsx)(`button`,{type:`button`,className:`cbox-close`,"data-tip":`Close (Esc)`,"aria-label":`Close`,onClick:a,children:(0,S.jsx)(U,{name:`x`,size:`sm`})});return(0,S.jsxs)(`div`,{className:`cbox thread-composer${E?` cbox-${E}`:``}`,onClick:e=>e.stopPropagation(),children:[(0,S.jsx)(`div`,{className:`cbox-head${O?` cbox-head-aud`:``}`,children:O?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(hc,{value:E,onChange:T}),(0,S.jsxs)(`span`,{className:`cbox-head-right`,children:[oe,se]})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`cbox-title`,children:p===`agent`?`Ask your agent`:n?`Comment on`:e}),oe,se]})}),m&&(0,S.jsxs)(`div`,{className:`cbox-cite`,children:[(0,S.jsx)(`span`,{className:`cbox-cite-label`,children:m.label}),(0,S.jsx)(`span`,{className:`cbox-cite-text`,children:m.text})]}),M&&(0,S.jsx)(`div`,{className:`cbox-tabs`,role:`tablist`,children:[`write`,`preview`].map(e=>(0,S.jsx)(`button`,{type:`button`,role:`tab`,className:`cbox-tab`,"aria-selected":_===e,onClick:()=>v(e),children:e===`write`?`Write`:`Preview`},e))}),M&&_===`write`&&(0,S.jsx)(`div`,{className:`cbox-mdbar`,children:gc.map((e,t)=>e===`sep`?(0,S.jsx)(`span`,{className:`cbox-mdsep`},t):(0,S.jsx)(`button`,{type:`button`,className:`cbox-mdb`,"data-tip":e.label,"aria-label":e.label,onClick:()=>te.current&&yc(te.current,e,F),children:(0,S.jsx)(U,{name:e.icon,size:`sm`})},t))}),(0,S.jsx)(`div`,{className:`cbox-body`,children:_===`write`?(0,S.jsx)(`textarea`,{ref:te,autoFocus:s,className:`thread-input cbox-input`,placeholder:t,value:P,onChange:e=>F(e.target.value),onKeyDown:e=>{e.key===`Escape`?a():(e.metaKey||e.ctrlKey)&&e.key===`Enter`?(e.preventDefault(),re()):(e.metaKey||e.ctrlKey)&&e.key===`.`&&O&&(e.preventDefault(),ie())}}):ne?(0,S.jsx)(pc,{className:`cbox-preview markdown`,text:P}):(0,S.jsx)(`div`,{className:`cbox-preview cbox-preview-empty`,children:`Nothing to preview yet.`})}),!ne&&!D&&(0,S.jsx)(`div`,{className:`cbox-openers`,children:_c.map(e=>(0,S.jsx)(`button`,{type:`button`,className:`cbox-opener`,title:e.text,onClick:()=>{F(e.text),ee(e.intent),v(`write`),te.current?.focus()},children:e.label},e.label))}),(0,S.jsxs)(`div`,{className:`cbox-foot`,children:[(0,S.jsx)(`button`,{type:`button`,className:`cbox-rich`,"aria-pressed":M,"data-tip":`Formatting and preview`,"aria-label":`Formatting and preview`,onClick:ae,children:`Aa`}),E===`pr`&&(0,S.jsx)(`span`,{className:`cbox-hint`,children:`Posts to GitHub when you submit the review`}),E===`agent`&&(0,S.jsx)(`span`,{className:`cbox-hint`,children:`Private, stays on this machine`}),E===void 0&&(0,S.jsx)(`span`,{className:`cbox-intent`,role:`radiogroup`,"aria-label":`What this comment wants`,children:vc.map(({intent:e,label:t,title:n})=>(0,S.jsx)(`button`,{type:`button`,role:`radio`,className:`cbox-intent-chip`,"aria-checked":I===e,title:n,onClick:()=>ee(e),children:t},t))}),M&&(0,S.jsxs)(`span`,{className:`cbox-attach`,children:[(0,S.jsx)(U,{name:`attach`,size:`sm`}),` Markdown supported`]}),(0,S.jsxs)(`span`,{className:`cbox-actions`,children:[(0,S.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-ghost`,onClick:a,children:`Close`}),i&&!D&&!k&&(0,S.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-outline`,disabled:!ne,onClick:()=>ne&&i(L(P),y,I),title:o?`add the comment and send it to your agent`:`add the comment and copy its prompt for your agent`,children:[(0,S.jsx)(U,{name:`send`,size:`sm`}),` Send to agent`]}),(0,S.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,disabled:!ne,onClick:re,title:D?`add this to your review; it posts to GitHub when you submit`:k?o?`send this to your agent; it never leaves this machine`:`add this and copy its prompt for your agent`:`leave this comment on the review`,children:[k&&(0,S.jsx)(U,{name:`send`,size:`sm`}),D?`Add to review`:k?`Send to agent`:`Add comment`,(0,S.jsx)(`span`,{className:`btn-kbd`,children:`⌘↵`})]})]})]})]})}var xc={fix:`Change`,question:`Question`},Sc={open:`Draft`,sent:`Sent`,addressed:`Answered`,resolved:`Resolved`},Cc={open:`mute`,sent:`mute`,addressed:`ok`,resolved:`mute`};function wc(e){let t=Math.max(0,e)/1e3;if(t<60)return`${t.toFixed(1)}s`;let n=Math.round(t);return`${Math.floor(n/60)}m ${String(n%60).padStart(2,`0`)}s`}function Tc(e){return e<=1?`next in line`:`#${e} in line`}function Ec({working:e,place:t,unanswered:n,followUp:r,since:i}){let a=n?`no answer, the agent moved on`:e?`with the agent${i?` · ${_a(i)}`:``}`:r?`follow-up on the way${i?` · ${_a(i)}`:``}`:`queued, ${Tc(t??1)}`;return(0,S.jsxs)(`div`,{className:`cmt thread-message thread-message-agent thread-message-pending${n?` thread-message-unanswered`:``}`,children:[(0,S.jsxs)(`div`,{className:`cmt-head`,children:[(0,S.jsx)(mc,{who:`agent`}),(0,S.jsx)(`span`,{className:`cmt-who cmt-who-agent`,children:`Agent`}),(0,S.jsx)(`span`,{className:`cmt-when`,children:a})]}),(0,S.jsx)(`div`,{className:`cmt-body pending-reply`,role:`status`,"aria-label":a,children:n?(0,S.jsx)(`span`,{className:`pending-none`,children:`Send it again, or resolve it if you've let it go.`}):(0,S.jsxs)(`span`,{className:`pending-dots`,children:[(0,S.jsx)(`i`,{}),(0,S.jsx)(`i`,{}),(0,S.jsx)(`i`,{})]})})]})}function Dc({code:e}){let[t,n]=(0,x.useState)(!1),r=e.split(`
86
86
  `);return(0,S.jsxs)(`div`,{className:`thread-context-wrap`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`thread-context-toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[(0,S.jsx)(`span`,{className:`chevron${t?``:` chevron-shut`}`,children:(0,S.jsx)(U,{name:`chev`,size:`sm`})}),`the commented change`,(0,S.jsxs)(`span`,{className:`thread-context-n`,children:[r.length,` `,r.length===1?`line`:`lines`]})]}),t&&(0,S.jsx)(`pre`,{className:`thread-context`,children:r.map((e,t)=>(0,S.jsx)(`span`,{className:`ctx-line${e.startsWith(`+`)?` ctx-add`:e.startsWith(`-`)?` ctx-del`:``}`,children:e===``?`
87
- `:e},`${t}-${e}`))})]})}function Oc(e,t){return e===`reviewer`||t===0?`commented`:`replied`}var kc={APPROVED:`approved`,CHANGES_REQUESTED:`requested changes`,COMMENTED:`reviewed`,DISMISSED:`dismissed`};function Ac(e){let t=[...e.messages].reverse().find(e=>e.author===`agent`);if(t){let e=/```suggestion\n[\s\S]*?```/.exec(t.text);return e?e[0]:t.text}return[...e.messages].reverse().find(e=>e.author===`reviewer`)?.text??``}function jc(e,t){(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),t())}function Mc({text:e,links:t}){return t?(0,S.jsx)(`div`,{onClick:e=>{let n=Po(e.target);n&&(e.preventDefault(),t.onJump(n.path,n.line))},children:(0,S.jsx)(pc,{className:`cmt-body markdown`,text:Fo(e,t.paths),paths:t.paths})}):(0,S.jsx)(pc,{className:`cmt-body markdown`,text:e})}function Nc({message:e,live:t,editing:n,agentConnected:r,onEdit:i,onCancelEdit:a,onAdd:o,onDismiss:s,onRestore:c}){let l=e.prComment,u=l.outcome,[d,f]=(0,x.useState)(!1);if(u||!t){let e=u?u.kind:`superseded`,t=u?u.kind===`added`?u.edited?`added to your review, edited`:`added to your review`:`dismissed`:`superseded by the reply below`;return(0,S.jsxs)(`div`,{className:`psc psc-done psc-${e}`,"data-testid":`pr-suggestion-receipt`,children:[(0,S.jsxs)(`div`,{className:`psc-done-line`,children:[(0,S.jsx)(`button`,{type:`button`,className:`thread-shut chevron${d?``:` chevron-shut`}`,"aria-expanded":d,"aria-label":d?`hide the suggested comment`:`show the suggested comment`,"data-tip":d?`hide the suggested comment`:`show the suggested comment`,onClick:()=>f(!d),children:(0,S.jsx)(U,{name:`chev`,size:`sm`})}),(0,S.jsx)(U,{name:`globe`,size:`sm`}),(0,S.jsxs)(`span`,{className:`psc-done-text`,children:[`Suggested PR comment `,(0,S.jsxs)(`span`,{className:`psc-done-status`,children:[`· `,t]})]}),e===`dismissed`&&c&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,title:`bring the suggestion back, with its buttons`,onClick:c,children:`Undo`})]}),d&&(0,S.jsx)(pc,{className:`psc-body markdown`,text:l.text})]})}return n?(0,S.jsx)(`div`,{className:`psc psc-editing`,children:(0,S.jsx)(bc,{title:`Suggested PR comment`,placeholder:`The review comment as GitHub will show it…`,fixedAudience:`pr`,initialText:l.text,agentConnected:r,onSubmit:e=>void o(e),onCancel:a})}):(0,S.jsxs)(`div`,{className:`psc`,"data-testid":`pr-suggestion`,children:[(0,S.jsxs)(`div`,{className:`psc-head`,children:[(0,S.jsx)(U,{name:`globe`,size:`sm`}),(0,S.jsx)(`span`,{children:`Suggested PR comment`}),(0,S.jsx)(`span`,{className:`psc-head-note`,children:`for the author, in your words`})]}),(0,S.jsx)(pc,{className:`psc-body markdown`,text:l.text}),(0,S.jsxs)(`div`,{className:`psc-foot`,children:[(0,S.jsx)(`span`,{className:`psc-hint`,children:`Draft · posts when you submit the review`}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm psc-add`,title:`a draft PR comment on these lines, in your review; it posts when you submit`,onClick:()=>void o(l.text),children:`Add as PR comment draft`}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-sm`,title:`rewrite it before it joins the review`,onClick:i,children:`Edit`}),s&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm`,"aria-label":`dismiss this suggested comment`,title:`pass on it; the thread stays open`,onClick:s,children:(0,S.jsx)(U,{name:`x`,size:`sm`})})]})]})}function Pc({thread:e,actions:t,showContext:n=!1,agentConnected:r=!1,working:i=!1,queuePosition:a,gone:o=!1,links:s,asides:c}){let l=fs(),u=it(e),d=e.github,f=u&&e.state===`open`&&d===void 0,p=d!==void 0&&e.id.startsWith(`gh:`),[m,h]=(0,x.useState)(null),[g,_]=(0,x.useState)(!1),[v,y]=(0,x.useState)(``),[b,C]=(0,x.useState)(!1),[w,T]=(0,x.useState)(null),[E,D]=(0,x.useState)(!1),[O,k]=(0,x.useState)(!1),[A,j]=(0,x.useState)(!1),[M,N]=(0,x.useState)(!1),[P,F]=(0,x.useState)(null),[I,ee]=(0,x.useState)(null),te=(0,x.useRef)(null),ne=(0,x.useRef)(null),L=(0,x.useRef)(void 0);(0,x.useEffect)(()=>()=>clearTimeout(L.current),[]);let re=(n=!0)=>{v.trim()&&(D(!1),t.reply(e.id,v,n).then(()=>y(``)).catch(()=>D(!0)))},ie=P?e.messages.findIndex(e=>e.id===P.id):-1,ae=ie===-1?0:e.messages.length-1-ie,oe=ie!==-1&&ct(e,ie),se=oe&&r&&(e.state===`sent`||e.state===`addressed`),ce=n=>t.edit!==void 0&&n.author===`reviewer`&&e.state!==`resolved`&&n.github===void 0,le=e=>{ee(null),F({id:e.id,draft:e.text})},ue=()=>{F(null),ee(null)},de=(n=!0)=>{if(!P||ie===-1)return;let r=P.draft.trim();if(r){if(r===e.messages[ie].text.trim())return ue();ee(null),t.edit(e.id,P.id,r,n).then(ue).catch(e=>ee(e instanceof Error&&e.message?e.message:`couldn't reach the diffo server — your text is still here; try again`))}},R=()=>(D(!1),T(null),t.send(e.id).then(({delivered:e,copied:t,prompt:n})=>{if(!e){if(!t){T(n??null);return}C(!0),clearTimeout(L.current),L.current=setTimeout(()=>C(!1),2500)}}).catch(()=>D(!0))),z=rt(e),B=(n,r)=>(D(!1),t.create(e.anchor,r,void 0,{audience:`pr`,origin:{threadId:e.id,messageId:n}}).then(()=>_(!1)).catch(()=>D(!0))),fe=n=>{t.dismissPrComment&&(D(!1),t.dismissPrComment(e.id,n).catch(()=>D(!0)))},pe=n=>{t.restorePrComment&&(D(!1),t.restorePrComment(e.id,n).catch(()=>D(!0)))},me=e.messages[e.messages.length-1]?.author,he=e.withheld===!0,ge=ms(e),_e=!u&&!he&&me===`reviewer`&&(e.state===`sent`||e.state===`addressed`),ve=e.state===`sent`&&_e&&!r,ye=u&&d?e.messages.filter(e=>e.author===`reviewer`&&e.github===void 0).length:0,be=lt(e)&&e.state===`open`,xe=!u&&r&&(e.state===`sent`||e.state===`addressed`||be),Se=O||v.trim()!==``,Ce=e.state!==`resolved`&&Se,we=e.state!==`resolved`&&!Se,Te=e.messages[e.messages.length-1],Ee=e.state!==`resolved`&&Te?.author===`agent`?Te.suggestedReply??null:null,De=Ee!==null&&v===``,V=()=>{Ee!==null&&(y(Ee),k(!0),requestAnimationFrame(()=>{let e=ne.current;e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))}))},Oe=e=>De&&(e.key===`Tab`||e.key===`ArrowRight`)&&!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&!e.altKey,ke=u?f?`Draft`:e.state===`resolved`?`Resolved`:`On GitHub`:be?`From the agent`:he?gs.note:e.state===`addressed`&&e.intent===`fix`?`Addressed`:Sc[e.state],Ae=u?f?`attn`:e.state===`resolved`?`mute`:`pr`:be||he?`attn`:Cc[e.state],je=(0,S.jsxs)(S.Fragment,{children:[e.queued?.resolve&&(0,S.jsx)(`span`,{className:`thread-badge thread-badge-pr`,children:`resolves when you submit`}),e.queued?.unresolve&&(0,S.jsx)(`span`,{className:`thread-badge thread-badge-pr`,children:`reopens when you submit`})]}),Me=(0,S.jsxs)(`span`,{className:`thread-marks`,children:[e.intent&&!st(e)&&(0,S.jsx)(`span`,{className:`thread-badge thread-badge-kind thread-kind-${e.intent}`,children:xc[e.intent]}),e.closingNote&&(0,S.jsx)(`span`,{className:`thread-badge`,children:`closing note`}),z!==null&&(0,S.jsxs)(`span`,{className:`thread-badge thread-badge-pr`,title:`your agent drafted a review comment for the author; it is under its reply`,children:[(0,S.jsx)(U,{name:`globe`,size:`sm`}),` suggests a PR comment`]}),d?.reviewState&&(0,S.jsx)(`span`,{className:`thread-badge thread-badge-${d.reviewState.toLowerCase()}`,children:kc[d.reviewState]}),d?.outdated&&(0,S.jsx)(`span`,{className:`thread-badge`,title:`the commented line is no longer in the diff`,children:`outdated`}),f&&(0,S.jsx)(`span`,{className:`thread-badge thread-badge-pr`,children:`posts when you submit`}),ye>0&&(0,S.jsxs)(`span`,{className:`thread-badge thread-badge-pr`,children:[ye===1?`reply posts`:`${ye} replies post`,` when you submit`]}),je,d?.url&&(0,S.jsxs)(`a`,{className:`thread-badge thread-badge-link`,href:d.url,target:`_blank`,rel:`noreferrer`,title:`open on GitHub`,children:[(0,S.jsx)(U,{name:`link`,size:`sm`}),` GitHub`]}),e.codeChanged&&(0,S.jsxs)(`span`,{className:`thread-badge`,children:[(0,S.jsx)(U,{name:`alert`,size:`sm`}),` code changed since this comment`]}),b&&(0,S.jsx)(`span`,{className:`thread-badge`,children:`prompt copied, paste it to your agent`}),!(be&&st(e))&&(0,S.jsx)(`span`,{className:`chip chip-${Ae}`,children:ke})]}),Ne=e.awaitingFollowUp===!0,Pe=!u&&(i||a!==void 0||e.unanswered||Ne)?(0,S.jsx)(Ec,{working:i,place:a,followUp:Ne,unanswered:e.unanswered===!0&&a===void 0&&!i,since:e.updatedAt}):null,Fe=(i||Ne)&&e.deliveredThrough?Date.parse(e.deliveredThrough):null,Ie=Fe===null?-1:e.messages.findIndex(e=>e.author===`reviewer`&&Date.parse(e.at)>Fe),Le=Ie===-1?e.messages.length:Ie,Re=ae>0?null:Pe,ze=e.state===`resolved`?(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void t.reopen(e.id),children:`Reopen`}):f&&t.remove?(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,title:`drop this draft; nothing was posted`,onClick:()=>void t.remove(e.id),children:`Discard draft`}):(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,title:d?`resolve on GitHub when you submit; until then it is only marked here`:void 0,onClick:()=>void t.resolve(e.id),children:`Resolve`}),Be=l&&!u&&z===null&&e.messages.length>0&&(0,S.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm thread-promote`,title:`turn this into a review comment for GitHub; you edit it before it joins the review`,onClick:()=>h(Ac(e)),children:[(0,S.jsx)(U,{name:`globe`,size:`sm`}),` Post as PR comment`]}),Ve=m!==null&&(0,S.jsx)(`div`,{className:`thread-aside-compose`,children:(0,S.jsx)(bc,{title:`Comment on PR`,placeholder:`The review comment as GitHub will show it…`,fixedAudience:`pr`,initialText:m,agentConnected:r,onSubmit:n=>{t.create(e.anchor,n,void 0,{audience:`pr`}),h(null)},onCancel:()=>h(null)})}),He=ve&&(0,S.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:R,children:[(0,S.jsx)(U,{name:`copy`,size:`sm`}),` Copy prompt`]}),Ue=ge&&(0,S.jsxs)(`button`,{type:`button`,className:`btn btn-sm ${Ce&&v.trim()!==``?`btn-outline`:`btn-primary`}`,onClick:R,title:r?`send this thread to your agent`:`mark sent and copy the prompt`,children:[(0,S.jsx)(U,{name:`send`,size:`sm`}),` Send`]}),We=e.state===`resolved`&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,title:`reopen this thread`,onClick:()=>void t.reopen(e.id),children:`Reopen`}),Ge=t.remove&&!p&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm btn-ghost-danger`,"aria-label":`delete this thread`,"data-tip":`delete this thread`,onClick:()=>void t.remove(e.id),children:(0,S.jsx)(U,{name:`trash`,size:`sm`})});if(e.state===`resolved`&&!A){let t=e.messages[0];return(0,S.jsxs)(`div`,{className:`thread thread-resolved thread-collapsed`,"data-thread-id":e.id,ref:te,onClick:e=>e.stopPropagation(),children:[(0,S.jsxs)(`button`,{type:`button`,className:`thread-collapsed-summary`,onClick:()=>j(!0),title:`expand this resolved thread`,children:[(0,S.jsx)(`span`,{className:`chip chip-mute`,children:`Resolved`}),je,(0,S.jsx)(`span`,{className:`thread-collapsed-text`,children:xs(t?.text??``)}),(0,S.jsx)(`span`,{className:`thread-collapsed-count`,children:e.messages.length>1?`${e.messages.length} messages`:``}),(0,S.jsx)(`span`,{className:`thread-collapsed-hint chevron chevron-shut`,children:(0,S.jsx)(U,{name:`chev`,size:`sm`})})]}),We,Ge]})}return(0,S.jsxs)(`div`,{className:`thread conv thread-${e.state}${u?` thread-public`:l?` thread-private`:``}${e.parentId?` thread-aside`:``}`,"data-thread-id":e.id,ref:te,onClick:e=>e.stopPropagation(),children:[(0,S.jsxs)(`div`,{className:`thread-head`,children:[(0,S.jsx)(`button`,{type:`button`,className:`thread-shut chevron${M?` chevron-shut`:``}`,"aria-expanded":!M,"data-tip":M?`expand this thread`:`collapse this thread`,"aria-label":M?`expand this thread`:`collapse this thread`,onClick:()=>N(!M),children:(0,S.jsx)(U,{name:`chev`,size:`sm`})}),l&&(0,S.jsxs)(`span`,{className:`thread-side thread-side-${u?`pr`:`agent`}`,title:u?`a review comment: on GitHub, or headed there when you submit`:`private: between you and your agent, never leaves this machine`,children:[(0,S.jsx)(U,{name:u?`globe`:`lock`,size:`sm`}),u?`PR comment`:`Private`]}),(0,S.jsx)(`span`,{className:`thread-where${o?` thread-where-gone`:``}`,title:o?d?.outdated?`outdated on GitHub: the line left the diff`:`this file is no longer in the changeset`:void 0,children:Fc(e,o)}),M&&e.messages.length>1&&(0,S.jsxs)(`span`,{className:`thread-where-n`,children:[e.messages.length,` messages`]}),Me,M&&We]}),M?(0,S.jsx)(`button`,{type:`button`,className:`thread-shut-peek`,onClick:()=>N(!1),children:xs(e.messages[0]?.text??``)}):(0,S.jsxs)(S.Fragment,{children:[n&&e.codeContext&&(0,S.jsx)(Dc,{code:e.codeContext}),ve&&(0,S.jsx)(`div`,{className:`thread-hint`,children:`waiting on your agent: paste the copied prompt into it; replies land here live`}),he&&(0,S.jsx)(`div`,{className:`thread-hint`,children:o?`your reply is held here: Send hands it over; Finish review will not, since this file has left the changeset`:`your reply is held here: Send hands it over now, or Finish review takes it with the batch`}),(0,S.jsxs)(`div`,{className:`thread-messages`,children:[e.messages.map((n,a)=>(0,S.jsxs)(x.Fragment,{children:[a===Le&&Re,(0,S.jsxs)(`div`,{className:`cmt thread-message thread-message-${n.author}${a===ie?` thread-message-editing`:``}${ie!==-1&&a>ie?` thread-message-cut`:``}`,children:[(0,S.jsxs)(`div`,{className:`cmt-head`,children:[(0,S.jsx)(mc,{who:n.author===`reviewer`?`you`:n.author===`agent`?`agent`:`github`,user:n.github?.user}),(0,S.jsx)(`span`,{className:`cmt-who cmt-who-${n.author}`,children:n.author===`reviewer`?`You`:n.author===`agent`?`Agent`:n.github?.user.login??`GitHub`}),(0,S.jsxs)(`span`,{className:`cmt-when`,children:[n.author===`agent`&&n.durationMs!==void 0?`answered in ${wc(n.durationMs)}`:`${Oc(n.author,a)} ${_a(n.at)}`,n.editedAt&&` · edited`,n.author===`github`&&` · on GitHub`,n.author===`reviewer`&&u&&n.github&&` · on GitHub`,n.author===`reviewer`&&u&&!n.github&&(f?` · draft`:` · posts when you submit`),a===0&&u&&e.origin&&(0,S.jsx)(`span`,{className:`cmt-origin`,title:`your agent wrote the first version of this comment; it posts as yours`,children:e.origin.edited?` · from your agent, edited`:` · from your agent`})]}),ce(n)&&P?.id!==n.id&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm cmt-edit`,"aria-label":`edit this message`,"aria-disabled":i||void 0,"data-tip":i?`the agent is answering — edit after it replies`:`edit this message`,onClick:()=>{i||le(n)},children:(0,S.jsx)(U,{name:`edit`,size:`sm`})})]}),P?.id===n.id?(0,S.jsxs)(`div`,{className:`cmt-edit-box`,children:[(0,S.jsx)(`textarea`,{autoFocus:!0,className:`cmt-edit-input`,"aria-label":`edit your message`,value:P.draft,onFocus:e=>e.currentTarget.setSelectionRange(e.currentTarget.value.length,e.currentTarget.value.length),onChange:e=>F({id:n.id,draft:e.target.value}),onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),ue()):jc(e,()=>de(!0))}}),I&&(0,S.jsx)(`div`,{className:`cmt-edit-error`,role:`alert`,children:I}),(0,S.jsxs)(`div`,{className:`cmt-edit-foot`,children:[(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:ue,children:`Cancel`}),se&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>de(!1),title:o?`save it without handing it over — Send takes it; the finish batch will not`:`save it without handing it over — Send or Finish takes it`,children:`Save`}),(0,S.jsxs)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>de(!0),title:se?`save the edit and hand the thread back to your agent — its withdrawn replies are named, and code it changed for them stays until it says otherwise`:oe?`save the edit — the thread waits for the agent, which is told its earlier replies were withdrawn`:`save the edit`,children:[se?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(U,{name:`send`,size:`sm`}),` Save & resend`]}):`Save`,(0,S.jsx)(`span`,{className:`btn-kbd`,children:`⌘↵`})]})]})]}):(0,S.jsx)(Mc,{text:n.text,links:s}),n.author===`agent`&&n.prComment&&(0,S.jsx)(Nc,{message:n,live:z?.id===n.id,editing:g&&z?.id===n.id,agentConnected:r,onEdit:()=>_(!0),onCancelEdit:()=>_(!1),onAdd:e=>B(n.id,e),onDismiss:t.dismissPrComment?()=>fe(n.id):void 0,onRestore:t.restorePrComment?()=>pe(n.id):void 0})]}),a===ie&&ae>0&&(0,S.jsx)(`div`,{className:`cmt-cut`,role:`note`,children:(0,S.jsxs)(`span`,{children:[`Saving removes the ${ae===1?`message`:`${ae} messages`} below`,oe&&` · the agent answers again`]})})]},n.id)),Le>=e.messages.length&&Re]}),c&&(0,S.jsx)(`div`,{className:`thread-asides`,children:c}),Ve,E&&(0,S.jsx)(`div`,{className:`thread-hint thread-hint-error`,children:`couldn't reach the diffo server; your text is still here, try again`}),w&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`thread-hint thread-hint-error`,children:`couldn't reach the clipboard; this browser blocked it. The thread is marked sent; select the prompt below and copy it by hand.`}),(0,S.jsx)(`pre`,{className:`invite-prompt`,children:w})]})]}),!M&&ie===-1&&(0,S.jsxs)(`div`,{className:`thread-foot${we||Ce?``:` thread-foot-bare`}`,children:[we&&Ee!==null&&(0,S.jsxs)(`div`,{className:`thread-offer replybar`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`thread-reply-stub thread-reply-stub-offer`,onClick:()=>k(!0),title:`the agent suggests this reply — click to write your own, Tab in the box takes this one`,children:[(0,S.jsx)(U,{name:`sparkle`,size:`sm`,className:`thread-offer-icon`}),(0,S.jsx)(`span`,{className:`thread-offer-text`,children:Ee})]}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-outline btn-sm thread-offer-use`,onClick:V,title:`take the suggested reply into the box, ready to edit or send`,children:`Use`})]}),we&&Ee===null&&(0,S.jsx)(`button`,{type:`button`,className:`thread-reply-stub replybar`,onClick:()=>k(!0),children:u?`Reply on GitHub…`:`Reply…`}),Ce&&(0,S.jsxs)(`div`,{className:`thread-input-wrap${De?` thread-input-wrap-ghost`:``}`,children:[De&&(0,S.jsx)(U,{name:`sparkle`,size:`sm`,className:`thread-offer-icon thread-ghost-icon`}),(0,S.jsx)(`textarea`,{autoFocus:!0,ref:ne,rows:1,className:`thread-input${De?` thread-input-ghost`:``}`,placeholder:De?Ee:u?`reply on GitHub, posts when you submit…`:`reply…`,"aria-description":De?`the agent offered this reply; press Tab to take it`:void 0,value:v,onChange:e=>y(e.target.value),onBlur:()=>{v.trim()||k(!1)},onKeyDown:e=>{Oe(e)?(e.preventDefault(),y(Ee)):e.key===`Escape`&&!v.trim()?k(!1):jc(e,()=>re(!0))}}),De&&(0,S.jsx)(`button`,{type:`button`,className:`thread-offer-kbd thread-ghost-hint`,onMouseDown:e=>e.preventDefault(),onClick:V,title:`take the suggested reply (Tab)`,children:`Tab`})]}),!we&&!Ce&&(0,S.jsx)(`span`,{className:`thread-spacer`}),Ce&&v.trim()!==``&&(0,S.jsxs)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>re(!0),title:xe?`reply and hand it to your agent in one go`:u?`reply on GitHub; it posts when you submit the review`:`write it into the thread`,children:[xe?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(U,{name:`send`,size:`sm`}),` Reply & send`]}):`Reply`,(0,S.jsx)(`span`,{className:`btn-kbd`,children:`⌘↵`})]}),Ce&&v.trim()!==``&&xe&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>re(!1),title:o?`write it into the thread without handing it over: Send takes it; the finish batch will not`:`write it into the thread without handing it over: Send or Finish takes it`,children:`Reply`}),Ue,He,Be,ze,e.state===`resolved`&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>j(!1),children:`Collapse`}),Ge]})]})}function Fc(e,t=!1){let n=e.anchor,r=e.github;if(r?.kind===`description`)return`Pull request description`;if(r?.kind===`review`)return`Review on the pull request`;if(r?.kind===`comment`||it(e)&&n.kind===`changeset`)return`Comment on the pull request`;let i=st(e)?`Agent comment`:e.messages[0]?.author===`github`?`${e.messages[0].github?.user.login??`GitHub`}'s comment`:it(e)?`Review comment`:`Comment`;return n.kind===`changeset`?st(e)?`${i} on the changeset`:`Note on the changeset`:n.kind===`layer`?t?`Layer “${n.title}”`:`${i} on this layer`:t?n.kind===`hunk`?`${n.path}:${pt(n)}`:n.path:n.kind===`hunk`?`${i} on ${n.endLine===void 0?`line`:`lines`} ${pt(n)}`:`${i} on this file`}function Ic({threads:e,actions:t,showContext:n=!1,agentConnected:r=!1,workingOn:i,queuedOn:a,gone:o=!1,links:s}){if(e.length===0)return null;let c=new Set(e.map(e=>e.id)),l=new Map;for(let t of e)if(t.parentId&&c.has(t.parentId)){let e=l.get(t.parentId);e?e.push(t):l.set(t.parentId,[t])}let u=(e,c)=>(0,S.jsx)(Pc,{thread:e,actions:t,showContext:n,agentConnected:r,working:i?.has(e.id)??!1,queuePosition:a?.get(e.id),gone:o,links:s,asides:c},e.id);return(0,S.jsx)(`div`,{className:`thread-list`,children:e.filter(e=>!(e.parentId&&c.has(e.parentId))).map(e=>{let t=l.get(e.id);return u(e,t?.map(e=>u(e)))})})}function Lc({stillTo:e,back:t,onOpen:n,onClose:r}){let i=e.filter(e=>e.working===!0).length,a=e.length-i,o=e.length===0&&t.length>0;(0,x.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),r())};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[r]);let s=[t.length>0?`${t.length} answered`:null,i>0?`${i} in progress`:null,a>0?`${a} waiting`:null].filter(Boolean);return(0,S.jsx)(`div`,{className:`monitor`,role:`dialog`,"aria-label":`Comments with your agent`,children:(0,S.jsxs)(`div`,{className:`monitor-inner`,children:[(0,S.jsx)(Rc,{stillTo:e,back:t}),s.length>0&&(0,S.jsx)(`div`,{className:`monitor-counts${o?` monitor-counts-done`:``}`,children:o?`all ${t.length} answered`:s.join(` · `)}),e.length>0&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`monitor-group`,children:[`Still to answer · `,e.length]}),(0,S.jsx)(`ul`,{className:`monitor-rows`,children:e.map(e=>(0,S.jsx)(Bc,{item:e,onOpen:n},e.thread.id))})]}),t.length>0&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`monitor-group`,children:[`Answered · `,t.length]}),(0,S.jsx)(`ul`,{className:`monitor-rows monitor-rows-done`,children:t.map(e=>(0,S.jsx)(Bc,{item:e,onOpen:n},e.thread.id))})]})]})})}function Rc({stillTo:e,back:t}){return(0,S.jsxs)(`div`,{className:`monitor-qbar`,"aria-hidden":!0,children:[t.map(e=>(0,S.jsx)(`i`,{className:`q-done`},e.thread.id)),e.map(e=>(0,S.jsx)(`i`,{className:e.working?`q-now`:`q-wait`},e.thread.id))]})}function zc(e){if(e.working)return{label:`working on it`,kind:`now`};if(e.queued!==void 0)return{label:Tc(e.queued),kind:`wait`};if(e.turn===`agent`)return{label:`sent`,kind:`wait`};if(e.turn===`resolved`)return{label:`settled`,kind:`done`};switch(e.outcome){case`fixed`:return{label:`fixed`,kind:`done`};case`answered`:return{label:`answered`,kind:`done`};case`changed`:return{label:`changed, no reply`,kind:`silent`};case`no-answer`:return{label:`no answer`,kind:`silent`};default:return{label:`back`,kind:`done`}}}function Bc({item:e,onOpen:t}){let[n,r]=(0,x.useState)(()=>Date.now());(0,x.useEffect)(()=>{if(e.working!==!0)return;let t=setInterval(()=>r(Date.now()),1e4);return()=>clearInterval(t)},[e.working]);let{label:i,kind:a}=zc(e),o=e.working===!0?Math.max(0,n-Date.parse(e.updatedAt)):void 0;return(0,S.jsx)(`li`,{children:(0,S.jsxs)(`button`,{type:`button`,className:`monitor-row`,onClick:()=>t(e),children:[(0,S.jsxs)(`span`,{className:`monitor-row-top`,children:[(0,S.jsxs)(`span`,{className:`monitor-st monitor-st-${a}`,children:[e.working===!0&&(0,S.jsx)(`span`,{className:`monitor-pulse`}),i]}),o!==void 0&&(0,S.jsxs)(`span`,{className:`monitor-took`,children:[wc(o),`…`]}),e.durationMs!==void 0&&!e.working&&(0,S.jsx)(`span`,{className:`monitor-took`,children:wc(e.durationMs)})]}),(0,S.jsxs)(`span`,{className:`monitor-q`,children:[(0,S.jsx)(`span`,{className:`monitor-anchor`,children:e.anchor??`the whole changeset`}),e.question]}),e.answer!==null&&(0,S.jsxs)(`span`,{className:`monitor-a`,children:[`↳ `,e.answer]})]})})}function Vc({status:e,onSetEnabled:t,onClose:n}){let[r,i]=(0,x.useState)(!1),a=e.source===`env`;return(0,S.jsxs)(At,{title:`Privacy`,onClose:n,footer:r?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{t(!1),i(!1)},children:`Turn off`}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>i(!1),children:`Keep sharing`})]}):void 0,children:[(0,S.jsxs)(`div`,{className:`privacy-row`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`pane-sw${e.enabled?` pane-sw-on`:``}`,role:`switch`,"aria-checked":e.enabled,disabled:a,onClick:()=>e.enabled?i(!0):t(!0),children:[(0,S.jsx)(`span`,{className:`pane-track`,"aria-hidden":`true`,children:(0,S.jsx)(`i`,{})}),`Share anonymous usage data`]}),(0,S.jsx)(`span`,{className:`privacy-state`,children:a?`Off: ${e.variable} is set in your environment`:e.enabled?`On`:`Off`})]}),(0,S.jsxs)(`p`,{className:`cov-note`,children:[`Two small events per review, opened and finished: the version, your OS, the kind of review, which agent, and counts. Never code, paths, or comment text. One random id per machine tells returning machines from new ones; turning this off deletes it.`,` `,(0,S.jsx)(`a`,{href:e.docs,target:`_blank`,rel:`noreferrer`,children:`What is sent`})]}),r&&(0,S.jsxs)(`p`,{className:`cov-note privacy-confirm`,children:[(0,S.jsx)(`strong`,{children:`Stop sharing?`}),` Diffo will send nothing more from this machine and delete its random id. You can turn it back on here any time.`]})]})}var Hc=[/(^|\/)pnpm-lock\.yaml$/,/(^|\/)package-lock\.json$/,/(^|\/)npm-shrinkwrap\.json$/,/(^|\/)yarn\.lock$/,/(^|\/)bun\.lockb?$/,/(^|\/)Cargo\.lock$/,/(^|\/)Gemfile\.lock$/,/(^|\/)composer\.lock$/,/(^|\/)go\.sum$/,/(^|\/)poetry\.lock$/,/(^|\/)uv\.lock$/,/\.min\.(js|css)$/,/\.(js|css)\.map$/,/\.snap$/];function Uc(e){let t=0;for(let n of e.hunks)for(let e of n.lines)e.kind!==`context`&&t++;return t}function Wc(e){return e.hunks.length===0?null:Hc.some(t=>t.test(e.path))?`generated`:Uc(e)>400?`large`:null}var Gc={fromTop:0,fromBottom:0};function Kc(e){return e.lines.filter(e=>e.kind!==`del`).length}function qc(e){return e.lines.filter(e=>e.kind!==`add`).length}function Jc(e){return Kc(e)===0?e.newStart+1:e.newStart}function Yc(e){return qc(e)===0?e.oldStart+1:e.oldStart}function Xc(e){return Jc(e)}function Zc(e){return Jc(e)+Kc(e)-1}function Qc(e){return Jc(e)-Yc(e)}function $c(e){return Jc(e)+Kc(e)-(Yc(e)+qc(e))}function el(e){let t=e.hunks;if(t.length===0)return[];let n=[],r=t[0];Xc(r)>1&&n.push({key:`top:${r.id}`,above:null,below:0,startNewNo:1,endNewNo:Xc(r)-1,offset:Qc(r)});for(let e=1;e<t.length;e++){let r=t[e-1],i=t[e],a=Zc(r)+1,o=Xc(i)-1;o>=a&&n.push({key:`${r.id}:${i.id}`,above:e-1,below:e,startNewNo:a,endNewNo:o,offset:Qc(i)})}let i=t[t.length-1],a=e.newLineCount;return typeof a==`number`&&a>Zc(i)&&n.push({key:`${i.id}:tail`,above:t.length-1,below:null,startNewNo:Zc(i)+1,endNewNo:a,offset:$c(i)}),n}function tl(e){return e.endNewNo-e.startNewNo+1}function nl(e,t){return Math.max(0,tl(e)-t.fromTop-t.fromBottom)}function rl(e,t,n,r){let i=[],a=Math.max(t.startNewNo,n),o=Math.min(t.endNewNo,r,e.length);for(let n=a;n<=o;n++){let r=e[n-1];if(r===void 0)break;i.push({kind:`context`,oldNo:n-t.offset,newNo:n,text:r})}return i}function il(e,t,n){if(nl(t,n)===0){let n=rl(e,t,t.startNewNo,t.endNewNo);return t.below===null?{top:n,bottom:[],merged:!0}:{top:[],bottom:n,merged:!0}}return{top:n.fromTop>0?rl(e,t,t.startNewNo,t.startNewNo+n.fromTop-1):[],bottom:n.fromBottom>0?rl(e,t,t.endNewNo-n.fromBottom+1,t.endNewNo):[],merged:!1}}var al={freshHunkIds:new Set,changedViewedHunkIds:new Set};function ol(e,t,n){if(!e)return al;let r=new Set,i=new Map;for(let t of e.files){let e=new Set;for(let n of t.hunks)e.add(n.id),r.add(n.id);i.set(t.path,e)}let a=new Set,o=new Set;for(let e of t.files){let t=new Set(e.hunks.map(e=>e.id)),s=[...i.get(e.path)??new Set].some(e=>n.has(e)&&!t.has(e));for(let t of e.hunks)r.has(t.id)||(a.add(t.id),s&&o.add(t.id))}return{freshHunkIds:a,changedViewedHunkIds:o}}function sl({decisions:e,open:t,onOpen:n,onJump:r,onComment:i}){return e.length===0?null:(0,S.jsxs)(`section`,{className:`ch-dec`,"aria-label":`Decisions`,children:[(0,S.jsx)(`div`,{className:`ch-dec-h`,children:`Decisions`}),e.map((e,a)=>(0,S.jsx)(ll,{resolved:e,open:t===a,onToggle:()=>n(t===a?null:a),onJump:r,onComment:i?()=>i(a):void 0},a))]})}function cl(e){return e.line===void 0?e.path:`${e.path}:${e.line}${e.endLine===void 0?``:`–${e.endLine}`}`}function ll({resolved:e,open:t,onToggle:n,onJump:r,onComment:i}){let{decision:a,places:o}=e,s=o.filter(e=>e.file);return(0,S.jsxs)(`div`,{className:`ch-dec-item${t?` ch-dec-item-open`:``}`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`ch-dec-main`,"aria-expanded":t,onClick:n,children:[(0,S.jsx)(`span`,{className:`chevron ch-dec-chev${t?``:` chevron-shut`}`,children:(0,S.jsx)(U,{name:`chev`,size:`sm`})}),(0,S.jsx)(`span`,{className:`ch-dec-text`,children:a.text})]}),t&&(0,S.jsxs)(`div`,{className:`ch-dec-card`,children:[a.detail&&(0,S.jsx)(pc,{text:a.detail,className:`ch-dec-detail markdown`}),(0,S.jsxs)(`div`,{className:`ch-dec-acts`,children:[s.map(e=>(0,S.jsxs)(`button`,{type:`button`,className:`ch-dec-place`,title:cl(e.at),onClick:()=>r(e.at.path,e.at.line??null),children:[(0,S.jsx)(`span`,{className:`ch-dec-place-path`,children:e.at.path}),e.at.line!==void 0&&(0,S.jsxs)(`span`,{className:`ch-dec-place-lines`,children:[e.at.line,e.at.endLine!==void 0&&`–${e.at.endLine}`]})]},cl(e.at))),s.length===0&&o.length>0&&(0,S.jsxs)(`span`,{className:`ch-dec-gone`,children:[o.length===1?`its file is`:`its files are`,` not in the changeset now`]}),i&&(0,S.jsx)(`button`,{type:`button`,className:`ch-dec-comment`,onClick:i,children:`Comment`})]})]})]})}var ul={ts:`typescript`,tsx:`tsx`,js:`javascript`,jsx:`jsx`,mjs:`javascript`,cjs:`javascript`,json:`json`,css:`css`,scss:`scss`,html:`html`,md:`markdown`,py:`python`,rb:`ruby`,go:`go`,rs:`rust`,java:`java`,kt:`kotlin`,swift:`swift`,c:`c`,h:`c`,cpp:`cpp`,hpp:`cpp`,cs:`csharp`,sh:`shellscript`,bash:`shellscript`,zsh:`shellscript`,yml:`yaml`,yaml:`yaml`,toml:`toml`,sql:`sql`,vue:`vue`,svelte:`svelte`,php:`php`,xml:`xml`,dockerfile:`docker`},dl={c:()=>X(()=>import(`./c-DWGmR78Y.js`),__vite__mapDeps([19,20])),cpp:()=>X(()=>import(`./cpp-CJIxL8VH.js`),__vite__mapDeps([21,22,20])),csharp:()=>X(()=>import(`./csharp-dmMxLVLW.js`),[]),css:()=>X(()=>import(`./css-DUjzNfgv.js`),__vite__mapDeps([23,24])),docker:()=>X(()=>import(`./docker-IyjqRm3v.js`),[]),go:()=>X(()=>import(`./go-rLFTqkRN.js`),[]),html:()=>X(()=>import(`./html-BlpXnbzK.js`),__vite__mapDeps([25,26,24,27])),java:()=>X(()=>import(`./java-DxlWrXwe.js`),__vite__mapDeps([28,29])),javascript:()=>X(()=>import(`./javascript-Yelw-5ZN.js`),__vite__mapDeps([30,27])),json:()=>X(()=>import(`./json-CaljABEy.js`),__vite__mapDeps([31,32])),jsx:()=>X(()=>import(`./jsx-hEbJ82HF.js`),__vite__mapDeps([33,34])),kotlin:()=>X(()=>import(`./kotlin-DhhofPvG.js`),[]),markdown:()=>X(()=>import(`./markdown-BYOwaDjH.js`),[]),php:()=>X(()=>import(`./php-CUj1wjLQ.js`),__vite__mapDeps([35,24,27,26,32,36,29,37])),python:()=>X(()=>import(`./python-gzcpVVnB.js`),[]),ruby:()=>X(()=>import(`./ruby-DgJVzwN8.js`),__vite__mapDeps([38,20,22,24,27,26,34,36,29,37,39,40,41,42])),rust:()=>X(()=>import(`./rust-DpiIf5JO.js`),[]),scss:()=>X(()=>import(`./scss-8bKmll0B.js`),__vite__mapDeps([43,24])),shellscript:()=>X(()=>import(`./shellscript-BiGZg9Om.js`),__vite__mapDeps([44,41])),sql:()=>X(()=>import(`./sql-BOsskAmu.js`),__vite__mapDeps([45,37])),svelte:()=>X(()=>import(`./svelte-DAcAPYhA.js`),__vite__mapDeps([46,24,27,39])),swift:()=>X(()=>import(`./swift-CyEgAFGc.js`),[]),toml:()=>X(()=>import(`./toml-CcmNWLt0.js`),[]),tsx:()=>X(()=>import(`./tsx-5f3ulCja.js`),__vite__mapDeps([47,40])),typescript:()=>X(()=>import(`./typescript-Utq2Cl8c.js`),__vite__mapDeps([48,39])),vue:()=>X(()=>import(`./vue-rALd9gPk.js`),__vite__mapDeps([49,24,27,26,32,39])),xml:()=>X(()=>import(`./xml-CoDIzWF0.js`),__vite__mapDeps([50,36,29])),yaml:()=>X(()=>import(`./yaml-CxbubiML.js`),__vite__mapDeps([51,42]))};function fl(e){let t=e.slice(e.lastIndexOf(`/`)+1).toLowerCase();return t===`dockerfile`?`docker`:ul[t.slice(t.lastIndexOf(`.`)+1)]??null}var pl=null;async function ml(){return pl||=(async()=>{let[{createHighlighterCore:e},{createOnigurumaEngine:t}]=await Promise.all([X(()=>import(`./core-eaqB-6jU.js`),[]),X(()=>import(`./engine-oniguruma-BmQGvQrV.js`),[])]);return e({themes:[X(()=>import(`./github-light-EUqPIrTm.js`),[]),X(()=>import(`./github-dark-C-LZuMrd.js`),[])],langs:[],engine:t(X(()=>import(`./wasm-BnjxR4X6.js`),[]))})})(),pl}var hl=new Map;function gl(e,t){if(e.getLoadedLanguages().includes(t))return null;let n=hl.get(t);if(n)return n;let r=dl[t];if(!r)return null;let i=r().then(t=>e.loadLanguage(t.default)).finally(()=>hl.delete(t));return hl.set(t,i),i}async function _l(e,t,n){let r=fl(t);if(!r||e.length===0)return null;try{let t=await ml();return await gl(t,r),t.getLoadedLanguages().includes(r)?t.codeToTokensBase(e.join(`
87
+ `:e},`${t}-${e}`))})]})}function Oc(e,t){return e===`reviewer`||t===0?`commented`:`replied`}var kc={APPROVED:`approved`,CHANGES_REQUESTED:`requested changes`,COMMENTED:`reviewed`,DISMISSED:`dismissed`};function Ac(e){let t=[...e.messages].reverse().find(e=>e.author===`agent`);if(t){let e=/```suggestion\n[\s\S]*?```/.exec(t.text);return e?e[0]:t.text}return[...e.messages].reverse().find(e=>e.author===`reviewer`)?.text??``}function jc(e,t){(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),t())}function Mc({text:e,links:t}){return t?(0,S.jsx)(`div`,{onClick:e=>{let n=Po(e.target);n&&(e.preventDefault(),t.onJump(n.path,n.line))},children:(0,S.jsx)(pc,{className:`cmt-body markdown`,text:Fo(e,t.paths),paths:t.paths})}):(0,S.jsx)(pc,{className:`cmt-body markdown`,text:e})}function Nc({message:e,live:t,editing:n,agentConnected:r,onEdit:i,onCancelEdit:a,onAdd:o,onDismiss:s,onRestore:c}){let l=e.prComment,u=l.outcome,[d,f]=(0,x.useState)(!1);if(u||!t){let e=u?u.kind:`superseded`,t=u?u.kind===`added`?u.edited?`added to your review, edited`:`added to your review`:`dismissed`:`superseded by the reply below`;return(0,S.jsxs)(`div`,{className:`psc psc-done psc-${e}`,"data-testid":`pr-suggestion-receipt`,children:[(0,S.jsxs)(`div`,{className:`psc-done-line`,children:[(0,S.jsx)(`button`,{type:`button`,className:`thread-shut chevron${d?``:` chevron-shut`}`,"aria-expanded":d,"aria-label":d?`hide the suggested comment`:`show the suggested comment`,"data-tip":d?`hide the suggested comment`:`show the suggested comment`,onClick:()=>f(!d),children:(0,S.jsx)(U,{name:`chev`,size:`sm`})}),(0,S.jsx)(U,{name:`globe`,size:`sm`}),(0,S.jsxs)(`span`,{className:`psc-done-text`,children:[`Suggested PR comment `,(0,S.jsxs)(`span`,{className:`psc-done-status`,children:[`· `,t]})]}),e===`dismissed`&&c&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,title:`bring the suggestion back, with its buttons`,onClick:c,children:`Undo`})]}),d&&(0,S.jsx)(pc,{className:`psc-body markdown`,text:l.text})]})}return n?(0,S.jsx)(`div`,{className:`psc psc-editing`,children:(0,S.jsx)(bc,{title:`Suggested PR comment`,placeholder:`The review comment as GitHub will show it…`,fixedAudience:`pr`,initialText:l.text,agentConnected:r,onSubmit:e=>void o(e),onCancel:a})}):(0,S.jsxs)(`div`,{className:`psc`,"data-testid":`pr-suggestion`,children:[(0,S.jsxs)(`div`,{className:`psc-head`,children:[(0,S.jsx)(U,{name:`globe`,size:`sm`}),(0,S.jsx)(`span`,{children:`Suggested PR comment`}),(0,S.jsx)(`span`,{className:`psc-head-note`,children:`for the author, in your words`})]}),(0,S.jsx)(pc,{className:`psc-body markdown`,text:l.text}),(0,S.jsxs)(`div`,{className:`psc-foot`,children:[(0,S.jsx)(`span`,{className:`psc-hint`,children:`Draft · posts when you submit the review`}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm psc-add`,title:`a draft PR comment on these lines, in your review; it posts when you submit`,onClick:()=>void o(l.text),children:`Add as PR comment draft`}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-sm`,title:`rewrite it before it joins the review`,onClick:i,children:`Edit`}),s&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm`,"aria-label":`dismiss this suggested comment`,title:`pass on it; the thread stays open`,onClick:s,children:(0,S.jsx)(U,{name:`x`,size:`sm`})})]})]})}function Pc({thread:e,actions:t,showContext:n=!1,agentConnected:r=!1,working:i=!1,queuePosition:a,gone:o=!1,links:s,asides:c}){let l=fs(),u=it(e),d=e.github,f=u&&e.state===`open`&&d===void 0,p=d!==void 0&&e.id.startsWith(`gh:`),[m,h]=(0,x.useState)(null),[g,_]=(0,x.useState)(!1),[v,y]=(0,x.useState)(``),[b,C]=(0,x.useState)(!1),[w,T]=(0,x.useState)(null),[E,D]=(0,x.useState)(!1),[O,k]=(0,x.useState)(!1),[A,j]=(0,x.useState)(!1),[M,N]=(0,x.useState)(!1),[P,F]=(0,x.useState)(null),[I,ee]=(0,x.useState)(null),te=(0,x.useRef)(null),ne=(0,x.useRef)(null),L=(0,x.useRef)(void 0);(0,x.useEffect)(()=>()=>clearTimeout(L.current),[]);let re=(n=!0)=>{v.trim()&&(D(!1),t.reply(e.id,v,n).then(()=>y(``)).catch(()=>D(!0)))},ie=P?e.messages.findIndex(e=>e.id===P.id):-1,ae=ie===-1?0:e.messages.length-1-ie,oe=ie!==-1&&ct(e,ie),se=oe&&r&&(e.state===`sent`||e.state===`addressed`),ce=n=>t.edit!==void 0&&n.author===`reviewer`&&e.state!==`resolved`&&n.github===void 0,le=e=>{ee(null),F({id:e.id,draft:e.text})},ue=()=>{F(null),ee(null)},de=(n=!0)=>{if(!P||ie===-1)return;let r=P.draft.trim();if(r){if(r===e.messages[ie].text.trim())return ue();ee(null),t.edit(e.id,P.id,r,n).then(ue).catch(e=>ee(e instanceof Error&&e.message?e.message:`couldn't reach the diffo server — your text is still here; try again`))}},R=()=>(D(!1),T(null),t.send(e.id).then(({delivered:e,copied:t,prompt:n})=>{if(!e){if(!t){T(n??null);return}C(!0),clearTimeout(L.current),L.current=setTimeout(()=>C(!1),2500)}}).catch(()=>D(!0))),z=rt(e),B=(n,r)=>(D(!1),t.create(e.anchor,r,void 0,{audience:`pr`,origin:{threadId:e.id,messageId:n}}).then(()=>_(!1)).catch(()=>D(!0))),fe=n=>{t.dismissPrComment&&(D(!1),t.dismissPrComment(e.id,n).catch(()=>D(!0)))},pe=n=>{t.restorePrComment&&(D(!1),t.restorePrComment(e.id,n).catch(()=>D(!0)))},me=e.messages[e.messages.length-1]?.author,he=e.withheld===!0,ge=ms(e),_e=!u&&!he&&me===`reviewer`&&(e.state===`sent`||e.state===`addressed`),ve=e.state===`sent`&&_e&&!r,ye=u&&d?e.messages.filter(e=>e.author===`reviewer`&&e.github===void 0).length:0,be=lt(e)&&e.state===`open`,xe=!u&&r&&(e.state===`sent`||e.state===`addressed`||be),Se=O||v.trim()!==``,Ce=e.state!==`resolved`&&Se,we=e.state!==`resolved`&&!Se,Te=e.messages[e.messages.length-1],Ee=e.state!==`resolved`&&Te?.author===`agent`?Te.suggestedReply??null:null,De=Ee!==null&&v===``,V=()=>{Ee!==null&&(y(Ee),k(!0),requestAnimationFrame(()=>{let e=ne.current;e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))}))},Oe=e=>De&&(e.key===`Tab`||e.key===`ArrowRight`)&&!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&!e.altKey,ke=u?f?`Draft`:e.state===`resolved`?`Resolved`:`On GitHub`:be?`From the agent`:he?gs.note:e.state===`addressed`&&e.intent===`fix`?`Addressed`:Sc[e.state],Ae=u?f?`attn`:e.state===`resolved`?`mute`:`pr`:be||he?`attn`:Cc[e.state],je=(0,S.jsxs)(S.Fragment,{children:[e.queued?.resolve&&(0,S.jsx)(`span`,{className:`thread-badge thread-badge-pr`,children:`resolves when you submit`}),e.queued?.unresolve&&(0,S.jsx)(`span`,{className:`thread-badge thread-badge-pr`,children:`reopens when you submit`})]}),Me=(0,S.jsxs)(`span`,{className:`thread-marks`,children:[e.intent&&!st(e)&&(0,S.jsx)(`span`,{className:`thread-badge thread-badge-kind thread-kind-${e.intent}`,children:xc[e.intent]}),e.closingNote&&(0,S.jsx)(`span`,{className:`thread-badge`,children:`closing note`}),z!==null&&(0,S.jsxs)(`span`,{className:`thread-badge thread-badge-pr`,title:`your agent drafted a review comment for the author; it is under its reply`,children:[(0,S.jsx)(U,{name:`globe`,size:`sm`}),` suggests a PR comment`]}),d?.reviewState&&(0,S.jsx)(`span`,{className:`thread-badge thread-badge-${d.reviewState.toLowerCase()}`,children:kc[d.reviewState]}),d?.outdated&&(0,S.jsx)(`span`,{className:`thread-badge`,title:`the commented line is no longer in the diff`,children:`outdated`}),f&&(0,S.jsx)(`span`,{className:`thread-badge thread-badge-pr`,children:`posts when you submit`}),ye>0&&(0,S.jsxs)(`span`,{className:`thread-badge thread-badge-pr`,children:[ye===1?`reply posts`:`${ye} replies post`,` when you submit`]}),je,d?.url&&(0,S.jsxs)(`a`,{className:`thread-badge thread-badge-link`,href:d.url,target:`_blank`,rel:`noreferrer`,title:`open on GitHub`,children:[(0,S.jsx)(U,{name:`link`,size:`sm`}),` GitHub`]}),e.codeChanged&&(0,S.jsxs)(`span`,{className:`thread-badge`,children:[(0,S.jsx)(U,{name:`alert`,size:`sm`}),` code changed since this comment`]}),b&&(0,S.jsx)(`span`,{className:`thread-badge`,children:`prompt copied, paste it to your agent`}),!(be&&st(e))&&(0,S.jsx)(`span`,{className:`chip chip-${Ae}`,children:ke})]}),Ne=e.awaitingFollowUp===!0,Pe=!u&&(i||a!==void 0||e.unanswered||Ne)?(0,S.jsx)(Ec,{working:i,place:a,followUp:Ne,unanswered:e.unanswered===!0&&a===void 0&&!i,since:e.updatedAt}):null,Fe=(i||Ne)&&e.deliveredThrough?Date.parse(e.deliveredThrough):null,Ie=Fe===null?-1:e.messages.findIndex(e=>e.author===`reviewer`&&Date.parse(e.at)>Fe),Le=Ie===-1?e.messages.length:Ie,Re=ae>0?null:Pe,ze=e.state===`resolved`?(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void t.reopen(e.id),children:`Reopen`}):f&&t.remove?(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,title:`drop this draft; nothing was posted`,onClick:()=>void t.remove(e.id),children:`Discard draft`}):(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,title:d?`resolve on GitHub when you submit; until then it is only marked here`:void 0,onClick:()=>void t.resolve(e.id),children:`Resolve`}),Be=l&&!u&&z===null&&e.messages.length>0&&(0,S.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm thread-promote`,title:`turn this into a review comment for GitHub; you edit it before it joins the review`,onClick:()=>h(Ac(e)),children:[(0,S.jsx)(U,{name:`globe`,size:`sm`}),` Post as PR comment`]}),Ve=m!==null&&(0,S.jsx)(`div`,{className:`thread-aside-compose`,children:(0,S.jsx)(bc,{title:`Comment on PR`,placeholder:`The review comment as GitHub will show it…`,fixedAudience:`pr`,initialText:m,agentConnected:r,onSubmit:n=>{t.create(e.anchor,n,void 0,{audience:`pr`}),h(null)},onCancel:()=>h(null)})}),He=ve&&(0,S.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:R,children:[(0,S.jsx)(U,{name:`copy`,size:`sm`}),` Copy prompt`]}),Ue=ge&&(0,S.jsxs)(`button`,{type:`button`,className:`btn btn-sm ${Ce&&v.trim()!==``?`btn-outline`:`btn-primary`}`,onClick:R,title:r?`send this thread to your agent`:`mark sent and copy the prompt`,children:[(0,S.jsx)(U,{name:`send`,size:`sm`}),` Send`]}),We=e.state===`resolved`&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,title:`reopen this thread`,onClick:()=>void t.reopen(e.id),children:`Reopen`}),Ge=t.remove&&!p&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm btn-ghost-danger`,"aria-label":`delete this thread`,"data-tip":`delete this thread`,onClick:()=>void t.remove(e.id),children:(0,S.jsx)(U,{name:`trash`,size:`sm`})});if(e.state===`resolved`&&!A){let t=e.messages[0];return(0,S.jsxs)(`div`,{className:`thread thread-resolved thread-collapsed`,"data-thread-id":e.id,ref:te,onClick:e=>e.stopPropagation(),children:[(0,S.jsxs)(`button`,{type:`button`,className:`thread-collapsed-summary`,onClick:()=>j(!0),title:`expand this resolved thread`,children:[(0,S.jsx)(`span`,{className:`chip chip-mute`,children:`Resolved`}),je,(0,S.jsx)(`span`,{className:`thread-collapsed-text`,children:xs(t?.text??``)}),(0,S.jsx)(`span`,{className:`thread-collapsed-count`,children:e.messages.length>1?`${e.messages.length} messages`:``}),(0,S.jsx)(`span`,{className:`thread-collapsed-hint chevron chevron-shut`,children:(0,S.jsx)(U,{name:`chev`,size:`sm`})})]}),We,Ge]})}return(0,S.jsxs)(`div`,{className:`thread conv thread-${e.state}${u?` thread-public`:l?` thread-private`:``}${e.parentId?` thread-aside`:``}`,"data-thread-id":e.id,ref:te,onClick:e=>e.stopPropagation(),children:[(0,S.jsxs)(`div`,{className:`thread-head`,children:[(0,S.jsx)(`button`,{type:`button`,className:`thread-shut chevron${M?` chevron-shut`:``}`,"aria-expanded":!M,"data-tip":M?`expand this thread`:`collapse this thread`,"aria-label":M?`expand this thread`:`collapse this thread`,onClick:()=>N(!M),children:(0,S.jsx)(U,{name:`chev`,size:`sm`})}),l&&(0,S.jsxs)(`span`,{className:`thread-side thread-side-${u?`pr`:`agent`}`,title:u?`a review comment: on GitHub, or headed there when you submit`:`private: between you and your agent, never leaves this machine`,children:[(0,S.jsx)(U,{name:u?`globe`:`lock`,size:`sm`}),u?`PR comment`:`Private`]}),(0,S.jsx)(`span`,{className:`thread-where${o?` thread-where-gone`:``}`,title:o?d?.outdated?`outdated on GitHub: the line left the diff`:`this file is no longer in the changeset`:void 0,children:Fc(e,o)}),M&&e.messages.length>1&&(0,S.jsxs)(`span`,{className:`thread-where-n`,children:[e.messages.length,` messages`]}),Me,M&&We]}),M?(0,S.jsx)(`button`,{type:`button`,className:`thread-shut-peek`,onClick:()=>N(!1),children:xs(e.messages[0]?.text??``)}):(0,S.jsxs)(S.Fragment,{children:[n&&e.codeContext&&(0,S.jsx)(Dc,{code:e.codeContext}),ve&&(0,S.jsx)(`div`,{className:`thread-hint`,children:`waiting on your agent: paste the copied prompt into it; replies land here live`}),he&&(0,S.jsx)(`div`,{className:`thread-hint`,children:o?`your reply is held here: Send hands it over; Finish review will not, since this file has left the changeset`:`your reply is held here: Send hands it over now, or Finish review takes it with the batch`}),(0,S.jsxs)(`div`,{className:`thread-messages`,children:[e.messages.map((n,a)=>(0,S.jsxs)(x.Fragment,{children:[a===Le&&Re,(0,S.jsxs)(`div`,{className:`cmt thread-message thread-message-${n.author}${a===ie?` thread-message-editing`:``}${ie!==-1&&a>ie?` thread-message-cut`:``}`,children:[(0,S.jsxs)(`div`,{className:`cmt-head`,children:[(0,S.jsx)(mc,{who:n.author===`reviewer`?`you`:n.author===`agent`?`agent`:`github`,user:n.github?.user}),(0,S.jsx)(`span`,{className:`cmt-who cmt-who-${n.author}`,children:n.author===`reviewer`?`You`:n.author===`agent`?`Agent`:n.github?.user.login??`GitHub`}),(0,S.jsxs)(`span`,{className:`cmt-when`,children:[n.author===`agent`&&n.durationMs!==void 0?`answered in ${wc(n.durationMs)}`:`${Oc(n.author,a)} ${_a(n.at)}`,n.editedAt&&` · edited`,n.author===`github`&&` · on GitHub`,n.author===`reviewer`&&u&&n.github&&` · on GitHub`,n.author===`reviewer`&&u&&!n.github&&(f?` · draft`:` · posts when you submit`),a===0&&u&&e.origin&&(0,S.jsx)(`span`,{className:`cmt-origin`,title:`your agent wrote the first version of this comment; it posts as yours`,children:e.origin.edited?` · from your agent, edited`:` · from your agent`})]}),ce(n)&&P?.id!==n.id&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm cmt-edit`,"aria-label":`edit this message`,"aria-disabled":i||void 0,"data-tip":i?`the agent is answering — edit after it replies`:`edit this message`,onClick:()=>{i||le(n)},children:(0,S.jsx)(U,{name:`edit`,size:`sm`})})]}),P?.id===n.id?(0,S.jsxs)(`div`,{className:`cmt-edit-box`,children:[(0,S.jsx)(`textarea`,{autoFocus:!0,className:`cmt-edit-input`,"aria-label":`edit your message`,value:P.draft,onFocus:e=>e.currentTarget.setSelectionRange(e.currentTarget.value.length,e.currentTarget.value.length),onChange:e=>F({id:n.id,draft:e.target.value}),onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),ue()):jc(e,()=>de(!0))}}),I&&(0,S.jsx)(`div`,{className:`cmt-edit-error`,role:`alert`,children:I}),(0,S.jsxs)(`div`,{className:`cmt-edit-foot`,children:[(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:ue,children:`Cancel`}),se&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>de(!1),title:o?`save it without handing it over — Send takes it; the finish batch will not`:`save it without handing it over — Send or Finish takes it`,children:`Save`}),(0,S.jsxs)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>de(!0),title:se?`save the edit and hand the thread back to your agent — its withdrawn replies are named, and code it changed for them stays until it says otherwise`:oe?`save the edit — the thread waits for the agent, which is told its earlier replies were withdrawn`:`save the edit`,children:[se?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(U,{name:`send`,size:`sm`}),` Save & resend`]}):`Save`,(0,S.jsx)(`span`,{className:`btn-kbd`,children:`⌘↵`})]})]})]}):(0,S.jsx)(Mc,{text:n.text,links:s}),n.author===`agent`&&n.prComment&&(0,S.jsx)(Nc,{message:n,live:z?.id===n.id,editing:g&&z?.id===n.id,agentConnected:r,onEdit:()=>_(!0),onCancelEdit:()=>_(!1),onAdd:e=>B(n.id,e),onDismiss:t.dismissPrComment?()=>fe(n.id):void 0,onRestore:t.restorePrComment?()=>pe(n.id):void 0})]}),a===ie&&ae>0&&(0,S.jsx)(`div`,{className:`cmt-cut`,role:`note`,children:(0,S.jsxs)(`span`,{children:[`Saving removes the ${ae===1?`message`:`${ae} messages`} below`,oe&&` · the agent answers again`]})})]},n.id)),Le>=e.messages.length&&Re]}),c&&(0,S.jsx)(`div`,{className:`thread-asides`,children:c}),Ve,E&&(0,S.jsx)(`div`,{className:`thread-hint thread-hint-error`,children:`couldn't reach the diffo server; your text is still here, try again`}),w&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`thread-hint thread-hint-error`,children:`couldn't reach the clipboard; this browser blocked it. The thread is marked sent; select the prompt below and copy it by hand.`}),(0,S.jsx)(`pre`,{className:`invite-prompt`,children:w})]})]}),!M&&ie===-1&&(0,S.jsxs)(`div`,{className:`thread-foot${we||Ce?``:` thread-foot-bare`}`,children:[we&&Ee!==null&&(0,S.jsxs)(`div`,{className:`thread-offer replybar`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`thread-reply-stub thread-reply-stub-offer`,onClick:()=>k(!0),title:`the agent suggests this reply — click to write your own, Tab in the box takes this one`,children:[(0,S.jsx)(U,{name:`sparkle`,size:`sm`,className:`thread-offer-icon`}),(0,S.jsx)(`span`,{className:`thread-offer-text`,children:Ee})]}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-outline btn-sm thread-offer-use`,onClick:V,title:`take the suggested reply into the box, ready to edit or send`,children:`Use`})]}),we&&Ee===null&&(0,S.jsx)(`button`,{type:`button`,className:`thread-reply-stub replybar`,onClick:()=>k(!0),children:u?`Reply on GitHub…`:`Reply…`}),Ce&&(0,S.jsxs)(`div`,{className:`thread-input-wrap${De?` thread-input-wrap-ghost`:``}`,children:[De&&(0,S.jsx)(U,{name:`sparkle`,size:`sm`,className:`thread-offer-icon thread-ghost-icon`}),(0,S.jsx)(`textarea`,{autoFocus:!0,ref:ne,rows:1,className:`thread-input${De?` thread-input-ghost`:``}`,placeholder:De?Ee:u?`reply on GitHub, posts when you submit…`:`reply…`,"aria-description":De?`the agent offered this reply; press Tab to take it`:void 0,value:v,onChange:e=>y(e.target.value),onBlur:()=>{v.trim()||k(!1)},onKeyDown:e=>{Oe(e)?(e.preventDefault(),y(Ee)):e.key===`Escape`&&!v.trim()?k(!1):jc(e,()=>re(!0))}}),De&&(0,S.jsx)(`button`,{type:`button`,className:`thread-offer-kbd thread-ghost-hint`,onMouseDown:e=>e.preventDefault(),onClick:V,title:`take the suggested reply (Tab)`,children:`Tab`})]}),!we&&!Ce&&(0,S.jsx)(`span`,{className:`thread-spacer`}),Ce&&v.trim()!==``&&(0,S.jsxs)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>re(!0),title:xe?`reply and hand it to your agent in one go`:u?`reply on GitHub; it posts when you submit the review`:`write it into the thread`,children:[xe?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(U,{name:`send`,size:`sm`}),` Reply & send`]}):`Reply`,(0,S.jsx)(`span`,{className:`btn-kbd`,children:`⌘↵`})]}),Ce&&v.trim()!==``&&xe&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>re(!1),title:o?`write it into the thread without handing it over: Send takes it; the finish batch will not`:`write it into the thread without handing it over: Send or Finish takes it`,children:`Reply`}),Ue,He,Be,ze,e.state===`resolved`&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>j(!1),children:`Collapse`}),Ge]})]})}function Fc(e,t=!1){let n=e.anchor,r=e.github;if(r?.kind===`description`)return`Pull request description`;if(r?.kind===`review`)return`Review on the pull request`;if(r?.kind===`comment`||it(e)&&n.kind===`changeset`)return`Comment on the pull request`;let i=st(e)?`Agent comment`:e.messages[0]?.author===`github`?`${e.messages[0].github?.user.login??`GitHub`}'s comment`:it(e)?`Review comment`:`Comment`;return n.kind===`changeset`?st(e)?`${i} on the changeset`:`Note on the changeset`:n.kind===`layer`?t?`Layer “${n.title}”`:`${i} on this layer`:t?n.kind===`hunk`?`${n.path}:${pt(n)}`:n.path:n.kind===`hunk`?`${i} on ${n.endLine===void 0?`line`:`lines`} ${pt(n)}`:`${i} on this file`}function Ic({threads:e,actions:t,showContext:n=!1,agentConnected:r=!1,workingOn:i,queuedOn:a,gone:o=!1,links:s}){if(e.length===0)return null;let c=new Set(e.map(e=>e.id)),l=new Map;for(let t of e)if(t.parentId&&c.has(t.parentId)){let e=l.get(t.parentId);e?e.push(t):l.set(t.parentId,[t])}let u=(e,c)=>(0,S.jsx)(Pc,{thread:e,actions:t,showContext:n,agentConnected:r,working:i?.has(e.id)??!1,queuePosition:a?.get(e.id),gone:o,links:s,asides:c},e.id);return(0,S.jsx)(`div`,{className:`thread-list`,children:e.filter(e=>!(e.parentId&&c.has(e.parentId))).map(e=>{let t=l.get(e.id);return u(e,t?.map(e=>u(e)))})})}function Lc({stillTo:e,back:t,onOpen:n,onClose:r}){let i=e.filter(e=>e.working===!0).length,a=e.length-i,o=e.length===0&&t.length>0;(0,x.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),r())};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[r]);let s=[t.length>0?`${t.length} answered`:null,i>0?`${i} in progress`:null,a>0?`${a} waiting`:null].filter(Boolean);return(0,S.jsx)(`div`,{className:`monitor`,role:`dialog`,"aria-label":`Comments with your agent`,children:(0,S.jsxs)(`div`,{className:`monitor-inner`,children:[(0,S.jsx)(Rc,{stillTo:e,back:t}),s.length>0&&(0,S.jsx)(`div`,{className:`monitor-counts${o?` monitor-counts-done`:``}`,children:o?`all ${t.length} answered`:s.join(` · `)}),e.length>0&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`monitor-group`,children:[`Still to answer · `,e.length]}),(0,S.jsx)(`ul`,{className:`monitor-rows`,children:e.map(e=>(0,S.jsx)(Bc,{item:e,onOpen:n},e.thread.id))})]}),t.length>0&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`monitor-group`,children:[`Answered · `,t.length]}),(0,S.jsx)(`ul`,{className:`monitor-rows monitor-rows-done`,children:t.map(e=>(0,S.jsx)(Bc,{item:e,onOpen:n},e.thread.id))})]})]})})}function Rc({stillTo:e,back:t}){return(0,S.jsxs)(`div`,{className:`monitor-qbar`,"aria-hidden":!0,children:[t.map(e=>(0,S.jsx)(`i`,{className:`q-done`},e.thread.id)),e.map(e=>(0,S.jsx)(`i`,{className:e.working?`q-now`:`q-wait`},e.thread.id))]})}function zc(e){if(e.working)return{label:`working on it`,kind:`now`};if(e.queued!==void 0)return{label:Tc(e.queued),kind:`wait`};if(e.turn===`agent`)return{label:`sent`,kind:`wait`};if(e.turn===`resolved`)return{label:`settled`,kind:`done`};switch(e.outcome){case`fixed`:return{label:`fixed`,kind:`done`};case`answered`:return{label:`answered`,kind:`done`};case`changed`:return{label:`changed, no reply`,kind:`silent`};case`no-answer`:return{label:`no answer`,kind:`silent`};default:return{label:`back`,kind:`done`}}}function Bc({item:e,onOpen:t}){let[n,r]=(0,x.useState)(()=>Date.now());(0,x.useEffect)(()=>{if(e.working!==!0)return;let t=setInterval(()=>r(Date.now()),1e4);return()=>clearInterval(t)},[e.working]);let{label:i,kind:a}=zc(e),o=e.working===!0?Math.max(0,n-Date.parse(e.updatedAt)):void 0;return(0,S.jsx)(`li`,{children:(0,S.jsxs)(`button`,{type:`button`,className:`monitor-row`,onClick:()=>t(e),children:[(0,S.jsxs)(`span`,{className:`monitor-row-top`,children:[(0,S.jsxs)(`span`,{className:`monitor-st monitor-st-${a}`,children:[e.working===!0&&(0,S.jsx)(`span`,{className:`monitor-pulse`}),i]}),o!==void 0&&(0,S.jsxs)(`span`,{className:`monitor-took`,children:[wc(o),`…`]}),e.durationMs!==void 0&&!e.working&&(0,S.jsx)(`span`,{className:`monitor-took`,children:wc(e.durationMs)})]}),(0,S.jsxs)(`span`,{className:`monitor-q`,children:[(0,S.jsx)(`span`,{className:`monitor-anchor`,children:e.anchor??`the whole changeset`}),e.question]}),e.answer!==null&&(0,S.jsxs)(`span`,{className:`monitor-a`,children:[`↳ `,e.answer]})]})})}function Vc({status:e,onSetEnabled:t,onClose:n}){let[r,i]=(0,x.useState)(!1),a=e.source===`env`;return(0,S.jsxs)(At,{title:`Privacy`,onClose:n,footer:r?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{t(!1),i(!1)},children:`Turn off`}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>i(!1),children:`Keep sharing`})]}):void 0,children:[(0,S.jsxs)(`div`,{className:`privacy-row`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`pane-sw${e.enabled?` pane-sw-on`:``}`,role:`switch`,"aria-checked":e.enabled,disabled:a,onClick:()=>e.enabled?i(!0):t(!0),children:[(0,S.jsx)(`span`,{className:`pane-track`,"aria-hidden":`true`,children:(0,S.jsx)(`i`,{})}),`Share anonymous usage data`]}),(0,S.jsx)(`span`,{className:`privacy-state`,children:a?`Off: ${e.variable} is set in your environment`:e.enabled?`On`:`Off`})]}),(0,S.jsxs)(`p`,{className:`cov-note`,children:[`Two small events per review, opened and finished: the version, your OS, the kind of review, which agent, and counts. Never code, paths, or comment text. One random id per machine tells returning machines from new ones; turning this off deletes it.`,` `,(0,S.jsx)(`a`,{href:e.docs,target:`_blank`,rel:`noreferrer`,children:`What is sent`})]}),r&&(0,S.jsxs)(`p`,{className:`cov-note privacy-confirm`,children:[(0,S.jsx)(`strong`,{children:`Stop sharing?`}),` Diffo will send nothing more from this machine and delete its random id. You can turn it back on here any time.`]})]})}var Hc=[/(^|\/)pnpm-lock\.yaml$/,/(^|\/)package-lock\.json$/,/(^|\/)npm-shrinkwrap\.json$/,/(^|\/)yarn\.lock$/,/(^|\/)bun\.lockb?$/,/(^|\/)Cargo\.lock$/,/(^|\/)Gemfile\.lock$/,/(^|\/)composer\.lock$/,/(^|\/)go\.sum$/,/(^|\/)poetry\.lock$/,/(^|\/)uv\.lock$/,/\.min\.(js|css)$/,/\.(js|css)\.map$/,/\.snap$/];function Uc(e){let t=0;for(let n of e.hunks)for(let e of n.lines)e.kind!==`context`&&t++;return t}function Wc(e){return e.hunks.length===0?null:Hc.some(t=>t.test(e.path))?`generated`:Uc(e)>400?`large`:null}var Gc={fromTop:0,fromBottom:0};function Kc(e){return e.lines.filter(e=>e.kind!==`del`).length}function qc(e){return e.lines.filter(e=>e.kind!==`add`).length}function Jc(e){return Kc(e)===0?e.newStart+1:e.newStart}function Yc(e){return qc(e)===0?e.oldStart+1:e.oldStart}function Xc(e){return Jc(e)}function Zc(e){return Jc(e)+Kc(e)-1}function Qc(e){return Jc(e)-Yc(e)}function $c(e){return Jc(e)+Kc(e)-(Yc(e)+qc(e))}function el(e){let t=e.hunks;if(t.length===0)return[];let n=[],r=t[0];Xc(r)>1&&n.push({key:`top:${r.id}`,above:null,below:0,startNewNo:1,endNewNo:Xc(r)-1,offset:Qc(r)});for(let e=1;e<t.length;e++){let r=t[e-1],i=t[e],a=Zc(r)+1,o=Xc(i)-1;o>=a&&n.push({key:`${r.id}:${i.id}`,above:e-1,below:e,startNewNo:a,endNewNo:o,offset:Qc(i)})}let i=t[t.length-1],a=e.newLineCount;return typeof a==`number`&&a>Zc(i)&&n.push({key:`${i.id}:tail`,above:t.length-1,below:null,startNewNo:Zc(i)+1,endNewNo:a,offset:$c(i)}),n}function tl(e){return e.endNewNo-e.startNewNo+1}function nl(e,t){return Math.max(0,tl(e)-t.fromTop-t.fromBottom)}function rl(e,t,n,r){let i=[],a=Math.max(t.startNewNo,n),o=Math.min(t.endNewNo,r,e.length);for(let n=a;n<=o;n++){let r=e[n-1];if(r===void 0)break;i.push({kind:`context`,oldNo:n-t.offset,newNo:n,text:r})}return i}function il(e,t,n){if(nl(t,n)===0){let n=rl(e,t,t.startNewNo,t.endNewNo);return t.below===null?{top:n,bottom:[],merged:!0}:{top:[],bottom:n,merged:!0}}return{top:n.fromTop>0?rl(e,t,t.startNewNo,t.startNewNo+n.fromTop-1):[],bottom:n.fromBottom>0?rl(e,t,t.endNewNo-n.fromBottom+1,t.endNewNo):[],merged:!1}}var al={freshHunkIds:new Set,changedViewedHunkIds:new Set};function ol(e,t,n){if(!e)return al;let r=new Set,i=new Map;for(let t of e.files){let e=new Set;for(let n of t.hunks)e.add(n.id),r.add(n.id);i.set(t.path,e)}let a=new Set,o=new Set;for(let e of t.files){let t=new Set(e.hunks.map(e=>e.id)),s=[...i.get(e.path)??new Set].some(e=>n.has(e)&&!t.has(e));for(let t of e.hunks)r.has(t.id)||(a.add(t.id),s&&o.add(t.id))}return{freshHunkIds:a,changedViewedHunkIds:o}}function sl({decisions:e,open:t,onOpen:n,onJump:r,onComment:i}){return e.length===0?null:(0,S.jsxs)(`section`,{className:`ch-dec`,"aria-label":`Decisions`,children:[(0,S.jsx)(`div`,{className:`ch-dec-h`,children:`Decisions`}),e.map((e,a)=>(0,S.jsx)(ll,{resolved:e,open:t===a,onToggle:()=>n(t===a?null:a),onJump:r,onComment:i?()=>i(a):void 0},a))]})}function cl(e){return e.line===void 0?e.path:`${e.path}:${e.line}${e.endLine===void 0?``:`–${e.endLine}`}`}function ll({resolved:e,open:t,onToggle:n,onJump:r,onComment:i}){let{decision:a,places:o}=e,s=o.filter(e=>e.file);return(0,S.jsxs)(`div`,{className:`ch-dec-item${t?` ch-dec-item-open`:``}`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`ch-dec-main`,"aria-expanded":t,onClick:n,children:[(0,S.jsx)(`span`,{className:`chevron ch-dec-chev${t?``:` chevron-shut`}`,children:(0,S.jsx)(U,{name:`chev`,size:`sm`})}),(0,S.jsx)(`span`,{className:`ch-dec-text`,children:a.text})]}),t&&(0,S.jsxs)(`div`,{className:`ch-dec-card`,children:[a.detail&&(0,S.jsx)(pc,{text:a.detail,className:`ch-dec-detail markdown`}),(0,S.jsxs)(`div`,{className:`ch-dec-acts`,children:[s.map(e=>(0,S.jsxs)(`button`,{type:`button`,className:`ch-dec-place`,title:cl(e.at),onClick:()=>r(e.at.path,e.at.line??null),children:[(0,S.jsx)(`span`,{className:`ch-dec-place-path`,children:e.at.path}),e.at.line!==void 0&&(0,S.jsxs)(`span`,{className:`ch-dec-place-lines`,children:[e.at.line,e.at.endLine!==void 0&&`–${e.at.endLine}`]})]},cl(e.at))),s.length===0&&o.length>0&&(0,S.jsxs)(`span`,{className:`ch-dec-gone`,children:[o.length===1?`its file is`:`its files are`,` not in the changeset now`]}),i&&(0,S.jsx)(`button`,{type:`button`,className:`ch-dec-comment`,onClick:i,children:`Comment`})]})]})]})}var ul={ts:`typescript`,tsx:`tsx`,js:`javascript`,jsx:`jsx`,mjs:`javascript`,cjs:`javascript`,json:`json`,css:`css`,scss:`scss`,html:`html`,md:`markdown`,py:`python`,rb:`ruby`,go:`go`,rs:`rust`,java:`java`,kt:`kotlin`,swift:`swift`,c:`c`,h:`c`,cpp:`cpp`,hpp:`cpp`,cs:`csharp`,sh:`shellscript`,bash:`shellscript`,zsh:`shellscript`,yml:`yaml`,yaml:`yaml`,toml:`toml`,sql:`sql`,vue:`vue`,svelte:`svelte`,php:`php`,xml:`xml`,dockerfile:`docker`},dl={c:()=>X(()=>import(`./c-DWGmR78Y.js`),__vite__mapDeps([19,20])),cpp:()=>X(()=>import(`./cpp-CJIxL8VH.js`),__vite__mapDeps([21,22,20])),csharp:()=>X(()=>import(`./csharp-dmMxLVLW.js`),[]),css:()=>X(()=>import(`./css-DUjzNfgv.js`),__vite__mapDeps([23,24])),docker:()=>X(()=>import(`./docker-IyjqRm3v.js`),[]),go:()=>X(()=>import(`./go-rLFTqkRN.js`),[]),html:()=>X(()=>import(`./html-BlpXnbzK.js`),__vite__mapDeps([25,26,24,27])),java:()=>X(()=>import(`./java-DxlWrXwe.js`),__vite__mapDeps([28,29])),javascript:()=>X(()=>import(`./javascript-Yelw-5ZN.js`),__vite__mapDeps([30,27])),json:()=>X(()=>import(`./json-CaljABEy.js`),__vite__mapDeps([31,32])),jsx:()=>X(()=>import(`./jsx-hEbJ82HF.js`),__vite__mapDeps([33,34])),kotlin:()=>X(()=>import(`./kotlin-DhhofPvG.js`),[]),markdown:()=>X(()=>import(`./markdown-BYOwaDjH.js`),[]),php:()=>X(()=>import(`./php-CUj1wjLQ.js`),__vite__mapDeps([35,24,27,26,32,36,29,37])),python:()=>X(()=>import(`./python-gzcpVVnB.js`),[]),ruby:()=>X(()=>import(`./ruby-DgJVzwN8.js`),__vite__mapDeps([38,20,22,24,27,26,34,36,29,37,39,40,41,42])),rust:()=>X(()=>import(`./rust-DpiIf5JO.js`),[]),scss:()=>X(()=>import(`./scss-8bKmll0B.js`),__vite__mapDeps([43,24])),shellscript:()=>X(()=>import(`./shellscript-BiGZg9Om.js`),__vite__mapDeps([44,41])),sql:()=>X(()=>import(`./sql-BOsskAmu.js`),__vite__mapDeps([45,37])),svelte:()=>X(()=>import(`./svelte-DAcAPYhA.js`),__vite__mapDeps([46,24,27,39])),swift:()=>X(()=>import(`./swift-CyEgAFGc.js`),[]),toml:()=>X(()=>import(`./toml-CcmNWLt0.js`),[]),tsx:()=>X(()=>import(`./tsx-5f3ulCja.js`),__vite__mapDeps([47,40])),typescript:()=>X(()=>import(`./typescript-Utq2Cl8c.js`),__vite__mapDeps([48,39])),vue:()=>X(()=>import(`./vue-rALd9gPk.js`),__vite__mapDeps([49,24,27,26,32,39])),xml:()=>X(()=>import(`./xml-CoDIzWF0.js`),__vite__mapDeps([50,36,29])),yaml:()=>X(()=>import(`./yaml-CxbubiML.js`),__vite__mapDeps([51,42]))};function fl(e){let t=e.slice(e.lastIndexOf(`/`)+1).toLowerCase();return t===`dockerfile`?`docker`:ul[t.slice(t.lastIndexOf(`.`)+1)]??null}var pl=null;async function ml(){return pl||=(async()=>{let[{createHighlighterCore:e},{createOnigurumaEngine:t}]=await Promise.all([X(()=>import(`./core-C38j58LO.js`),[]),X(()=>import(`./engine-oniguruma-Ds-VbuSq.js`),[])]);return e({themes:[X(()=>import(`./github-light-EUqPIrTm.js`),[]),X(()=>import(`./github-dark-C-LZuMrd.js`),[])],langs:[],engine:t(X(()=>import(`./wasm-BnjxR4X6.js`),[]))})})(),pl}var hl=new Map;function gl(e,t){if(e.getLoadedLanguages().includes(t))return null;let n=hl.get(t);if(n)return n;let r=dl[t];if(!r)return null;let i=r().then(t=>e.loadLanguage(t.default)).finally(()=>hl.delete(t));return hl.set(t,i),i}async function _l(e,t,n){let r=fl(t);if(!r||e.length===0)return null;try{let t=await ml();return await gl(t,r),t.getLoadedLanguages().includes(r)?t.codeToTokensBase(e.join(`
88
88
  `),{lang:r,theme:n?`github-dark`:`github-light`,includeExplanation:`scopeName`}):null}catch{return null}}var vl=/^(text|comment|string|keyword|storage|punctuation|constant\.(numeric|language|character)|variable\.language|support\.type\.primitive)\b/;function yl(e){let t=e.explanation;if(!t||t.length===0)return[{content:e.content,sym:!0}];let n=[];for(let e of t){let t=!e.scopes.some(e=>vl.test(e.scopeName)),r=n[n.length-1];r&&r.sym===t?r.content+=e.content:n.push({content:e.content,sym:t})}return n}var bl=400,xl=.3,Sl=400,Cl=3,wl=.65;function Tl(e){return e.match(/[A-Za-z0-9_$]+|\s+|[^A-Za-z0-9_$\s]/g)??[]}function El(e,t){let n=e.length,r=t.length,i=Array.from({length:n+1},()=>new Uint32Array(r+1));for(let a=n-1;a>=0;a--){let n=i[a],o=i[a+1];for(let i=r-1;i>=0;i--)n[i]=e[a]===t[i]?o[i+1]+1:Math.max(o[i],n[i+1])}let a=[],o=0,s=0;for(;o<n&&s<r;)e[o]===t[s]?(a.push([o,s]),o++,s++):i[o+1][s]>=i[o][s+1]?o++:s++;return a}function Dl(e,t){let n=[],r=0;for(let i=0;i<e.length;i++){let a=e[i].length;if(!t[i]){let e=n[n.length-1];e&&e.end===r?e.end=r+a:n.push({start:r,end:r+a})}r+=a}return n.filter(t=>e.length>0&&t.end>t.start)}function Ol(e){let t=[];for(let n of e){let e=t[t.length-1];e&&n.start-e.end<=Cl?e.end=n.end:t.push({...n})}return t}var kl=(e,t)=>t===0?0:e.reduce((e,t)=>e+(t.end-t.start),0)/t;function Al(e,t){if(e.length>bl||t.length>bl)return null;let n=Tl(e),r=Tl(t);if(n.length===0||r.length===0)return null;let i=El(n,r),a=Array(n.length).fill(!1),o=Array(r.length).fill(!1),s=0;for(let[e,t]of i)a[e]=!0,o[t]=!0,s+=n[e].length;let c=2*s/(e.length+t.length);if(c<xl)return null;let l=Ol(Dl(n,a)),u=Ol(Dl(r,o));return kl(l,e.length)>wl||kl(u,t.length)>wl?{similarity:c,del:[],add:[]}:{similarity:c,del:l,add:u}}function jl(e,t,n){let r=[];if(t.length===n.length){for(let i=0;i<t.length;i++){let a=Al(e[t[i]].text,e[n[i]].text);a&&r.push([t[i],n[i],a])}return r}if(t.length*n.length>Sl)return r;let i=[];for(let r of t)for(let t of n){let n=Al(e[r].text,e[t].text);n&&i.push({d:r,a:t,cmp:n})}i.sort((e,t)=>t.cmp.similarity-e.cmp.similarity);let a=new Set,o=new Set;for(let{d:e,a:t,cmp:n}of i)a.has(e)||o.has(t)||(a.add(e),o.add(t),r.push([e,t,n]));return r}function Ml(e){let t=e.map(()=>null),n=0;for(;n<e.length;){if(e[n].kind!==`del`){n++;continue}let r=[];for(;n<e.length&&e[n].kind===`del`;)r.push(n++);let i=[];for(;n<e.length&&e[n].kind===`add`;)i.push(n++);if(i.length!==0)for(let[n,a,o]of jl(e,r,i))o.del.length>0&&(t[n]=o.del),o.add.length>0&&(t[a]=o.add)}return t}function Nl(e,t,n){if(!n||n.length===0)return[{text:e,changed:!1}];let r=[],i=0,a=(t,n,i)=>{if(n<=t)return;let a=e.slice(t,n),o=r[r.length-1];o&&o.changed===i?o.text+=a:r.push({text:a,changed:i})};for(let r of n){let n=Math.max(0,r.start-t),o=Math.min(e.length,r.end-t);o<=0||n>=e.length||o<=n||(a(i,n,!1),a(n,o,!0),i=Math.max(i,o))}return a(i,e.length,!1),r}function Pl(e,t){let n=new Set(e.flatMap(e=>e.hunks.map(e=>e.id))),r=new Set(e.map(e=>e.path)),i=new Map,a=new Map,o=new Map,s=[],c=(e,t,n)=>{let r=e.get(t);r?r.push(n):e.set(t,[n])};for(let l of t){let t=l.anchor;if(t.kind===`changeset`)s.push(l);else if(t.kind===`layer`)c(o,t.layerId,l);else if(t.kind===`file`)r.has(t.path)?c(a,t.path,l):s.push(l);else if(n.has(t.hunkId))c(i,t.hunkId,l);else{let n=Fl(e,t);n===null?r.has(t.path)?c(a,t.path,l):s.push(l):c(i,n,l)}}return{byHunk:i,byFile:a,byLayer:o,changeset:s}}function Fl(e,t){let n=e.find(e=>e.path===t.path);return n?n.hunks.find(e=>Bl(e.lines,t)!==-1)?.id??null:null}function Il(e,t){let n=new Map;for(let r of e){let e=[...t.byFile.get(r.path)??[]];for(let n of r.hunks)e.push(...t.byHunk.get(n.id)??[]);e.length>0&&n.set(r.path,e)}return n}function Ll(e,t,n){return n.kind===`del`?n.oldNo===null?null:{kind:`hunk`,hunkId:e,path:t,side:`old`,line:n.oldNo}:n.newNo===null?null:{kind:`hunk`,hunkId:e,path:t,side:`new`,line:n.newNo}}function Rl(e,t,n,r,i){let a=Math.max(0,Math.min(r,i)),o=Math.min(n.length-1,Math.max(r,i)),s=null;for(let r=a;r<=o&&!s;r++)s=Ll(e,t,n[r]);if(!s)return null;let c=e=>s.side===`old`?e.kind===`add`?null:e.oldNo:e.kind===`del`?null:e.newNo,l=s.line;for(let e=o;e>a;e--){let t=c(n[e]);if(t!==null){l=t;break}}return l>s.line?{...s,endLine:l}:s}function zl(e,t,n){return e.findIndex(e=>t===`old`?e.kind!==`add`&&e.oldNo===n:e.kind!==`del`&&e.newNo===n)}function Bl(e,t){return zl(e,t.side,t.line)}function Vl(e,t){if(t.endLine!==void 0){let n=zl(e,t.side,t.endLine);if(n!==-1)return n}return Bl(e,t)}function Hl(e,t){let n=new Map;for(let r of t){if(r.anchor.kind!==`hunk`)continue;let t=Vl(e,r.anchor),i=n.get(t);i?i.push(r):n.set(t,[r])}return n}function Ul(e,t){let n=new Set;for(let r of t){let t=r.anchor;if(t.kind!==`hunk`||t.endLine===void 0)continue;let i=Bl(e,t),a=Vl(e,t);if(i!==-1&&a!==-1)for(let e=Math.min(i,a);e<=Math.max(i,a);e++)n.add(e)}return n}function Wl(e,t){let n=new Set;for(let r of t){let t=r.anchor;if(t.kind!==`hunk`||t.endLine===void 0)continue;let i=Bl(e,t),a=Vl(e,t);i!==-1&&a!==-1&&n.add(Math.min(i,a))}return n}function Gl(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r.kind===`context`){t.push({left:{line:r,idx:n},right:{line:r,idx:n}}),n++;continue}let i=[],a=[];for(;n<e.length&&e[n].kind===`del`;)i.push({line:e[n],idx:n}),n++;for(;n<e.length&&e[n].kind===`add`;)a.push({line:e[n],idx:n}),n++;let o=Math.max(i.length,a.length);for(let e=0;e<o;e++)t.push({left:i[e]??null,right:a[e]??null})}return t}function Kl({gap:e}){if(e.remaining<=0)return null;let t=(e,t)=>{e.stopPropagation(),t()};if(e.remaining<=20)return(0,S.jsx)(`span`,{className:`gap-x`,children:(0,S.jsx)(`button`,{type:`button`,className:`gap-btn`,"data-tip":`expand all (${e.remaining} hidden ${e.remaining===1?`line`:`lines`})`,"aria-label":`expand all ${e.remaining} hidden lines`,onClick:n=>t(n,e.onAll),children:(0,S.jsx)(U,{name:`unfold`,size:`sm`})})});let n=e.canUp&&e.canDown;return(0,S.jsxs)(`span`,{className:`gap-x${n?` gap-x-2`:``}`,children:[e.canDown&&(0,S.jsx)(`button`,{type:`button`,className:`gap-btn`,"data-tip":`expand down (20 lines)`,"aria-label":`expand down`,onClick:n=>t(n,e.onDown),children:(0,S.jsx)(U,{name:`down`,size:n?`xs`:`sm`})}),e.canUp&&(0,S.jsx)(`button`,{type:`button`,className:`gap-btn`,"data-tip":`expand up (20 lines)`,"aria-label":`expand up`,onClick:n=>t(n,e.onUp),children:(0,S.jsx)(U,{name:`up`,size:n?`xs`:`sm`})})]})}function ql({onCollapse:e}){return(0,S.jsx)(`button`,{type:`button`,className:`gap-fold`,"data-tip":`hide expanded lines`,"aria-label":`hide expanded lines`,onClick:t=>{t.stopPropagation(),e()},children:(0,S.jsx)(U,{name:`fold`,size:`sm`})})}var Jl=`couldn't read more context; the file may have changed since`;function Yl({gap:e}){return(0,S.jsx)(`div`,{className:`gap-band`,children:(0,S.jsx)(`table`,{className:`hunk-lines`,children:(0,S.jsx)(`tbody`,{children:(0,S.jsx)(`tr`,{className:`hunk-boundary${e.merged?` hunk-boundary-merged`:``}`,children:(0,S.jsx)(`td`,{colSpan:4,children:(0,S.jsxs)(`span`,{className:`hunk-boundary-bar`,children:[!e.merged&&(0,S.jsx)(Kl,{gap:e}),(e.merged||e.expanded)&&(0,S.jsx)(ql,{onCollapse:e.onCollapse}),e.failed&&(0,S.jsx)(`span`,{className:`hunk-expand-failed`,role:`status`,children:Jl})]})})})})})})}function Xl(e,t){let n=Ro(),[r,i]=(0,x.useState)([]);return(0,x.useEffect)(()=>{let r=!1,a=e.filter(e=>e.kind!==`add`),o=e.filter(e=>e.kind!==`del`);return Promise.all([_l(a.map(e=>e.text),t,n),_l(o.map(e=>e.text),t,n)]).then(([t,n])=>{if(r)return;let a=0,o=0;i(e.map(e=>e.kind===`add`?n?.[o++]??null:(e.kind===`del`||o++,t?.[a++]??null)))}).catch(()=>{}),()=>{r=!0}},[e,t,n]),r}function Zl({line:e,tokens:t,ranges:n}){if(!t)return(0,S.jsx)(S.Fragment,{children:Nl(e.text,0,n??null).map((e,t)=>e.changed?(0,S.jsx)(`span`,{className:`word-changed`,children:e.text},t):(0,S.jsx)(`span`,{children:e.text},t))});let r=0;return(0,S.jsx)(S.Fragment,{children:t.map((e,t)=>{let i=e.color?{color:e.color}:void 0;return yl(e).map((e,a)=>{let o=r;r+=e.content.length;let s=e.sym?void 0:`nosym`,c=Nl(e.content,o,n??null);return c.length===1&&!c[0].changed?(0,S.jsx)(`span`,{style:i,className:s,children:e.content},`${t}:${a}`):(0,S.jsx)(`span`,{style:i,className:s,children:c.map((e,t)=>e.changed?(0,S.jsx)(`span`,{className:`word-changed`,children:e.text},t):(0,S.jsx)(`span`,{children:e.text},t))},`${t}:${a}`)})})})}var Ql={add:`+`,del:`−`,context:` `};function $l(e,t){return{"data-side":t,"data-old":e.oldNo??void 0,"data-new":e.newNo??void 0}}function eu(){return(0,S.jsx)(`span`,{className:`line-range-glyph`,"aria-hidden":`true`,children:(0,S.jsx)(U,{name:`chat`,size:`sm`})})}function tu(e,t,n,...r){let i=e=>e!==void 0&&r.some(t=>t!==void 0&&e.has(t)),a=n!=null&&r.includes(n);return`${i(e)?` line-sel`:``}${i(t)?` line-ranged`:``}${a?` line-focus`:``}`}function nu(e,t){if(e)return n=>{n.button===0&&(n.preventDefault(),e(t,n.shiftKey))}}function ru({onClick:e}){return(0,S.jsx)(`button`,{type:`button`,className:`line-comment-btn`,"data-tip":`comment on this line; drag down to take more lines`,"aria-label":`comment on this line, or drag down to comment on a range`,onClick:t=>{t.stopPropagation(),t.shiftKey||e()},children:(0,S.jsx)(U,{name:`plus`,size:`sm`})})}function iu({lines:e,tokens:t,ranges:n,extraFor:r,extraClass:i,onComment:a,onRowClick:o,focusRow:s,onGutterDown:c,onLineEnter:l,selRows:u,rangeRows:d,rangeStarts:f,boundary:p}){return(0,S.jsx)(`table`,{className:`hunk-lines`,children:(0,S.jsxs)(`tbody`,{children:[p,e.map((e,p)=>{let m=r?.(p),h=nu(c,p);return(0,S.jsxs)(x.Fragment,{children:[(0,S.jsxs)(`tr`,{className:`line line-${e.kind}${tu(u,d,s,p)}`,onMouseEnter:l?()=>l(p):void 0,onClick:o?()=>o(p):void 0,children:[(0,S.jsxs)(`td`,{className:`line-no`,onMouseDown:h,children:[f?.has(p)&&(0,S.jsx)(eu,{}),a&&(0,S.jsx)(ru,{onClick:()=>a(p)}),e.oldNo??``]}),(0,S.jsx)(`td`,{className:`line-no`,onMouseDown:h,children:e.newNo??``}),(0,S.jsx)(`td`,{className:`line-marker`,children:Ql[e.kind]}),(0,S.jsx)(`td`,{className:`line-code`,...$l(e,e.kind===`del`?`base`:`head`),children:(0,S.jsx)(Zl,{line:e,tokens:t[p]??null,ranges:n?.[p]})})]}),m&&(0,S.jsx)(`tr`,{className:`thread-row${i?.(p)??``}`,children:(0,S.jsx)(`td`,{colSpan:4,children:m})})]},p)})]})})}function au({lines:e,tokens:t,ranges:n,extraFor:r,extraClass:i,onComment:a,onRowClick:o,focusRow:s,onGutterDown:c,onLineEnter:l,selRows:u,rangeRows:d,rangeStarts:f,boundary:p}){let m=Gl(e),h=e=>o&&e!==void 0?()=>o(e):void 0,g=e=>l&&e!==void 0?()=>l(e):void 0;return(0,S.jsxs)(`table`,{className:`hunk-lines hunk-lines-split`,children:[(0,S.jsxs)(`colgroup`,{children:[(0,S.jsx)(`col`,{className:`split-col-no`}),(0,S.jsx)(`col`,{}),(0,S.jsx)(`col`,{className:`split-col-no`}),(0,S.jsx)(`col`,{})]}),(0,S.jsxs)(`tbody`,{children:[p,m.map((e,o)=>{let l=e.left?r?.(e.left.idx):null,p=e.right&&e.right.idx!==e.left?.idx?r?.(e.right.idx):null;return(0,S.jsxs)(x.Fragment,{children:[(0,S.jsxs)(`tr`,{className:`line${tu(u,d,s,e.left?.idx,e.right?.idx)}`,children:[(0,S.jsxs)(`td`,{className:`line-no`,onMouseDown:e.left?nu(c,e.left.idx):void 0,onMouseEnter:g(e.left?.idx),onClick:h(e.left?.idx),children:[e.left&&f?.has(e.left.idx)&&(0,S.jsx)(eu,{}),a&&e.left&&(0,S.jsx)(ru,{onClick:()=>a(e.left.idx)}),e.left?.line.oldNo??``]}),(0,S.jsx)(`td`,{className:`line-half line-half-${e.left?.line.kind??`empty`}`,...e.left&&$l(e.left.line,`base`),onMouseEnter:g(e.left?.idx),onClick:h(e.left?.idx),children:e.left&&(0,S.jsx)(Zl,{line:e.left.line,tokens:t[e.left.idx]??null,ranges:n?.[e.left.idx]})}),(0,S.jsxs)(`td`,{className:`line-no`,onMouseDown:e.right?nu(c,e.right.idx):void 0,onMouseEnter:g(e.right?.idx),onClick:h(e.right?.idx),children:[e.right&&f?.has(e.right.idx)&&(0,S.jsx)(eu,{}),a&&e.right&&(0,S.jsx)(ru,{onClick:()=>a(e.right.idx)}),e.right?.line.newNo??``]}),(0,S.jsx)(`td`,{className:`line-half line-half-${e.right?.line.kind??`empty`}`,...e.right&&$l(e.right.line,`head`),onMouseEnter:g(e.right?.idx),onClick:h(e.right?.idx),children:e.right&&(0,S.jsx)(Zl,{line:e.right.line,tokens:t[e.right.idx]??null,ranges:n?.[e.right.idx]})})]}),(l||p)&&(0,S.jsx)(`tr`,{className:`thread-row${l&&e.left&&i?.(e.left.idx)||p&&e.right&&i?.(e.right.idx)||``}`,children:(0,S.jsxs)(`td`,{colSpan:4,children:[l,p]})})]},o)})]})]})}function ou({hunk:e,fresh:t=!1,changedSinceReview:n=!1,changedSinceViewed:r=!1,viewed:i=!1,selected:a=!1,onSelect:o,viewMode:s=`unified`,linesAbove:c,linesBelow:l,gapAbove:u=null,threads:d=[],reviewActions:f,agentConnected:p,workingOn:m,queuedOn:h,composeRequested:g=!1,onComposeHandled:_}){let[v,y]=(0,x.useState)(null),[b,C]=(0,x.useState)(null),[w,T]=(0,x.useState)(null);(0,x.useEffect)(()=>{a||T(null)},[a]);let E=(0,x.useMemo)(()=>(c?.length??0)===0&&(l?.length??0)===0?e.lines:[...c??[],...e.lines,...l??[]],[c,l,e.lines]),D=Xl(E,e.path),O=(0,x.useMemo)(()=>Ml(E),[E]);(0,x.useEffect)(()=>{if(!g)return;let e=w??E.findIndex(e=>e.kind!==`context`),t=e===-1?0:e;y({at:t,edge:t}),_?.()},[g]);let[k,A]=(0,x.useState)(``),[j,M]=(0,x.useState)(void 0),N=()=>{y(null),A(``),M(void 0)};(0,x.useEffect)(()=>{if(!b)return;let e=()=>{C(null),y({at:b.start,edge:b.end})};return window.addEventListener(`mouseup`,e),()=>window.removeEventListener(`mouseup`,e)},[b]);let P=f?(e,t)=>{if(t&&v){y({at:v.at,edge:e});return}C({start:e,end:e})}:void 0,F=b?e=>C(t=>t&&t.end!==e?{...t,end:e}:t):void 0,I=Hl(E,d),ee=I.get(-1)??[],te=(0,x.useMemo)(()=>Ul(E,d),[E,d]),ne=(0,x.useMemo)(()=>Wl(E,d),[E,d]),[L,re]=(0,x.useState)(null),ie=(0,x.useMemo)(()=>{let e=b??(v?{start:v.at,end:v.edge}:null),t=new Set(L?.rows??[]);if(e)for(let n=Math.min(e.start,e.end);n<=Math.max(e.start,e.end);n++)t.add(n);return t},[b,v,L]),ae=t=>{if(!f)return null;let n=Rl(e.id,e.path,E,t.at,t.edge);if(!n)return null;let r=`${e.path.slice(e.path.lastIndexOf(`/`)+1)}:${pt(n)}`,i=e=>e?{kind:`changeset`}:n;return(0,S.jsx)(bc,{title:`Comment on ${r}`,placeholder:`Leave a comment…`,scope:{label:r,canWiden:!0,adjust:{up:t.edge>0?()=>y({at:t.at,edge:t.edge-1}):void 0,down:t.edge<E.length-1?()=>y({at:t.at,edge:t.edge+1}):void 0}},agentConnected:p,draft:k,onDraft:A,draftIntent:j,onDraftIntent:M,onSubmit:(e,t,n,r)=>{r?f.create(i(t),e,n,{audience:r}):f.create(i(t),e,n),N()},onSend:(e,t,n)=>{f.create(i(t),e,n).then(e=>f.send(e.id)),N()},onCancel:N})},oe=e=>{let t=I.get(e);return!t||Ul(E,t).size===0?``:` thread-row-ranged${L?.idx===e?` thread-row-lit`:``}`},se=e=>{let t=I.get(e),n=v!==null&&Math.max(v.at,v.edge)===e?ae(v):null;if(!t&&!n)return null;let r=t?Ul(E,t):new Set;return(0,S.jsxs)(S.Fragment,{children:[t&&f&&(0,S.jsx)(`div`,{className:`thread-anchor-scope`,onMouseEnter:r.size>0?()=>re({idx:e,rows:r}):void 0,onMouseLeave:r.size>0?()=>re(null):void 0,children:(0,S.jsx)(Ic,{threads:t,actions:f,agentConnected:p,workingOn:m,queuedOn:h})}),n]})},ce=n&&!i,le=[`hunk`];ce&&le.push(`hunk-since-review`),t&&le.push(`hunk-fresh`),i&&le.push(`hunk-viewed`),a&&le.push(`hunk-selected`);let ue=e.lines.filter(e=>e.kind!==`add`).length,de=e.lines.filter(e=>e.kind!==`del`).length,R=u?.merged??!1,z=!ce&&r&&(0,S.jsx)(`span`,{className:`hunk-badge`,children:`changed since you read it`}),B=(0,S.jsx)(`tr`,{className:`hunk-boundary${R?` hunk-boundary-merged`:``}`,title:ce?`the agent changed this since your last review`:void 0,children:(0,S.jsx)(`td`,{colSpan:4,children:(0,S.jsxs)(`span`,{className:`hunk-boundary-bar`,children:[u&&!R&&(0,S.jsx)(Kl,{gap:u}),u&&(R||u.expanded)&&(0,S.jsx)(ql,{onCollapse:u.onCollapse}),!R&&(0,S.jsxs)(`span`,{className:`hunk-at`,title:`hunk position in the file`,children:[`@@ −`,e.oldStart,`,`,ue,` +`,e.newStart,`,`,de,` @@`,e.context!==void 0&&(0,S.jsxs)(`span`,{className:`hunk-at-scope`,children:[` `,e.context]})]}),u?.failed&&(0,S.jsx)(`span`,{className:`hunk-expand-failed`,role:`status`,children:Jl}),z]})})});return(0,S.jsxs)(`div`,{className:le.join(` `),"data-hunk-id":e.id,onClick:()=>o?.(e.id),children:[s===`split`?(0,S.jsx)(au,{lines:E,tokens:D,ranges:O,extraFor:se,extraClass:oe,onComment:f?e=>y({at:e,edge:e}):void 0,onRowClick:f?T:void 0,focusRow:w,onGutterDown:P,onLineEnter:F,selRows:ie,rangeRows:te,rangeStarts:ne,boundary:B}):(0,S.jsx)(iu,{lines:E,tokens:D,ranges:O,extraFor:se,extraClass:oe,onComment:f?e=>y({at:e,edge:e}):void 0,onRowClick:f?T:void 0,focusRow:w,onGutterDown:P,onLineEnter:F,selRows:ie,rangeRows:te,rangeStarts:ne,boundary:B}),ee.length>0&&f&&(0,S.jsx)(Ic,{threads:ee,actions:f,agentConnected:p,workingOn:m,queuedOn:h})]})}function su(e,t){return`/api/file?path=${encodeURIComponent(e)}&side=${t}`}function cu({file:e}){let t=e.status!==`added`,n=e.status!==`deleted`,r=e.oldPath??e.path;return(0,S.jsxs)(`div`,{className:`image-diff`,children:[t&&(0,S.jsxs)(`figure`,{className:`image-side image-side-base`,children:[(0,S.jsx)(`img`,{src:su(r,`base`),alt:`${r} (base)`}),(0,S.jsx)(`figcaption`,{children:`base`})]}),n&&(0,S.jsxs)(`figure`,{className:`image-side image-side-head`,children:[(0,S.jsx)(`img`,{src:su(e.path,`head`),alt:`${e.path} (head)`}),(0,S.jsx)(`figcaption`,{children:`head`})]})]})}function lu(e){return e.status!==`deleted`&&/\.(md|markdown)$/i.test(e.path)}function uu({path:e,onClose:t}){let[n,r]=(0,x.useState)(null),[i,a]=(0,x.useState)(!1);return(0,x.useEffect)(()=>{let t=!1;return(async()=>{try{let n=await fetch(`/api/file?path=${encodeURIComponent(e)}&side=head`);if(!n.ok)throw Error(`/api/file → ${n.status}`);let i=await n.text();t||r(i)}catch{t||a(!0)}})(),()=>{t=!0}},[e]),(0,S.jsx)(At,{title:e,className:`md-preview`,onClose:t,children:i?(0,S.jsx)(`div`,{className:`file-stub`,children:`couldn't read this file; it may have just changed on disk`}):n===null?(0,S.jsxs)(`div`,{"aria-hidden":`true`,children:[(0,S.jsx)(`div`,{className:`shimmer`}),(0,S.jsx)(`div`,{className:`shimmer`}),(0,S.jsx)(`div`,{className:`shimmer shimmer-short`})]}):(0,S.jsx)(pc,{className:`markdown md-doc`,text:n,docPath:e})})}function du({navHidden:e,onToggleNav:t,left:n,total:r,hunksRead:i,hunksTotal:a,hunkAt:o=0,hunkCount:s=0,query:c=``,onClearQuery:l,hideReviewed:u,onHideReviewed:d,hideTests:f,onHideTests:p,testCount:m,onlyChanged:h,onOnlyChanged:g,changedCount:_,viewMode:v,onSetViewMode:y,allCollapsed:b,onToggleCollapseAll:x,stats:C,layer:w}){let T=r-n,E=w?w.progress:a!==void 0&&i!==void 0&&a>0?i/a:r===0?0:T/r,D=n===0?`all reviewed`:`${T} of ${r} files`,O=m>0||f,k=_>0||h,A=T>0||u,j=`${m} test ${m===1?`file`:`files`}`,M=c.trim(),N=w?w.stats:C;return(0,S.jsxs)(`div`,{className:`pane-bar`,children:[t&&(0,S.jsx)(`button`,{type:`button`,className:`pane-icon pane-nav`,onClick:t,"data-tip":`${e?`Show`:`Hide`} the file list (b)`,"aria-label":`${e?`Show`:`Hide`} the file list`,"aria-pressed":!e,children:(0,S.jsx)(U,{name:`sidebar`,size:`md`})}),E!==null&&(0,S.jsx)(`span`,{className:`prog-track prog-track-pane`,"aria-hidden":`true`,children:(0,S.jsx)(`i`,{style:{width:`${Math.round(E*100)}%`}})}),w?(0,S.jsx)(`span`,{className:`pane-left`,title:w.title,children:w.text}):(0,S.jsx)(`span`,{className:`pane-left`,title:`${T} of ${r} files marked reviewed`,children:D}),N&&(N.additions>0||N.deletions>0)&&(0,S.jsxs)(`span`,{className:`pane-size`,title:w?`lines added and removed in this layer`:`lines added and removed across the changeset`,children:[N.additions>0&&(0,S.jsxs)(`span`,{className:`stat-add`,children:[`+`,N.additions.toLocaleString(`en-US`)]}),N.deletions>0&&(0,S.jsxs)(`span`,{className:`stat-del`,children:[`−`,N.deletions.toLocaleString(`en-US`)]})]}),o>0&&s>0&&(0,S.jsxs)(`span`,{className:`pane-at`,title:`the selected hunk — j / k move it`,children:[`hunk `,o,` / `,s]}),(0,S.jsx)(`span`,{className:`grow`}),!w&&M!==``&&l&&(0,S.jsxs)(`button`,{type:`button`,className:`pane-q`,title:`Showing only files matching “${M}”; click to clear`,"aria-label":`Clear the file filter “${M}”`,onClick:l,children:[(0,S.jsx)(U,{name:`search`,size:`sm`}),(0,S.jsx)(`span`,{className:`pane-q-word`,children:M}),(0,S.jsx)(U,{name:`x`,size:`sm`})]}),!w&&k&&(0,S.jsx)(fu,{on:h,onChange:g,label:_>0?`Only ${_} since review`:`Only since review`,onLabel:_>0?`only ${_} since review`:void 0}),!w&&A&&(0,S.jsx)(fu,{on:u,onChange:d,label:T>0?`Hide ${T} reviewed`:`Hide reviewed`,onLabel:T>0?`${T} reviewed hidden`:void 0}),O&&(0,S.jsx)(fu,{on:f,onChange:p,label:m>0?`Hide ${j}`:`Hide tests`,onLabel:m>0?`${j} hidden`:void 0}),(0,S.jsx)(`span`,{className:`pane-sep`}),(0,S.jsxs)(`span`,{className:`pane-modes`,role:`group`,"aria-label":`Diff layout`,children:[(0,S.jsx)(`button`,{type:`button`,className:`pane-icon`,"aria-pressed":v===`unified`,"data-tip":`Unified diff (u)`,"aria-label":`Unified diff`,onClick:()=>y(`unified`),children:(0,S.jsx)(U,{name:`unified`,size:`sm`})}),(0,S.jsx)(`button`,{type:`button`,className:`pane-icon`,"aria-pressed":v===`split`,"data-tip":`Split diff (u)`,"aria-label":`Split diff`,onClick:()=>y(`split`),children:(0,S.jsx)(U,{name:`split`,size:`sm`})})]}),(0,S.jsx)(`button`,{type:`button`,className:`pane-icon`,"aria-pressed":b,"data-tip":`${b?`Expand`:`Collapse`} all files`,"aria-label":`${b?`Expand`:`Collapse`} all files`,onClick:x,children:(0,S.jsx)(U,{name:`fold`,size:`sm`})}),w&&(w.prev||w.next)&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`pane-sep`}),(0,S.jsxs)(`span`,{className:`ch-pager`,children:[w.prev&&(0,S.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,title:`Previous layer: ${w.prev.title} ([)`,"aria-label":`Previous layer: ${w.prev.title}`,onClick:w.prev.onGo,children:[`‹ `,(0,S.jsx)(`span`,{className:`ch-pager-t`,children:w.prev.title})]}),w.next&&(0,S.jsxs)(`button`,{type:`button`,className:`btn btn-sm`,title:`Next layer: ${w.next.title} (])`,"aria-label":`Next layer: ${w.next.title}`,onClick:w.next.onGo,children:[(0,S.jsx)(`span`,{className:`ch-pager-t`,children:w.next.title}),` ›`,` `,(0,S.jsx)(`span`,{className:`kbd`,"aria-hidden":`true`,children:`]`})]})]})]})]})}function fu({on:e,onChange:t,label:n,onLabel:r}){return(0,S.jsxs)(`button`,{type:`button`,className:`pane-sw${e?` pane-sw-on`:``}`,role:`switch`,"aria-checked":e,onClick:()=>t(!e),children:[(0,S.jsx)(`span`,{className:`pane-track`,"aria-hidden":`true`,children:(0,S.jsx)(`i`,{})}),e&&r?r:n]})}var pu=e=>e.toLocaleString(`en-US`);function mu({read:e,total:t,excludedTests:n,excludedUnchanged:r,stats:i,unsent:a,onFinish:o,onIncludeExcluded:s,onDismiss:c,shape:l}){let u=n+r,d=a!==void 0&&a>0?a:0,f=u===0?`That's the whole changeset`:`That's everything you asked to see`,p=t===0?1:Math.min(1,(u===0?t:e)/t),m=(0,S.jsxs)(`div`,{className:`done-stats`,children:[(0,S.jsxs)(`span`,{className:`done-stat`,children:[(0,S.jsx)(`span`,{className:`done-n`,children:u===0?pu(t):`${e} of ${t}`}),` `,t===1?`file`:`files`,` read`]}),u===0&&i&&(i.additions>0||i.deletions>0)&&(0,S.jsxs)(`span`,{className:`done-stat done-size`,children:[i.additions>0&&(0,S.jsxs)(`span`,{className:`stat-add`,children:[`+`,pu(i.additions)]}),i.deletions>0&&(0,S.jsxs)(`span`,{className:`stat-del`,children:[`−`,pu(i.deletions)]})]}),d>0&&(0,S.jsxs)(`span`,{className:`done-stat done-unsent`,role:`img`,"aria-label":`${d} comment${d===1?``:`s`} waiting to go back to your agent`,title:`${d} comment${d===1?``:`s`} waiting to go back to your agent`,children:[(0,S.jsx)(U,{name:`chat`,size:`sm`}),d]})]}),h=(0,S.jsxs)(`div`,{className:`done-meter`,children:[(0,S.jsx)(`div`,{className:`done-bar`,"aria-hidden":`true`,children:(0,S.jsx)(`i`,{style:{"--p":p}})}),m]}),g=u>0&&(0,S.jsxs)(`div`,{className:`done-caveat`,children:[(0,S.jsx)(U,{name:`eye-off`,size:`sm`}),(0,S.jsxs)(`span`,{className:`done-caveat-text`,children:[n>0&&(0,S.jsxs)(S.Fragment,{children:[n,` test `,n===1?`file was`:`files were`,` hidden`]}),n>0&&r>0&&`, and `,r>0&&(0,S.jsxs)(S.Fragment,{children:[r,` `,r===1?`file is`:`files are`,` outside this round`]}),`; nobody reviewed `,u===1?`it`:`them`,`.`]}),s&&(0,S.jsxs)(`button`,{type:`button`,className:`done-caveat-act`,onClick:s,children:[`Review `,u===1?`it`:`them`,` too`]})]}),_=(0,S.jsx)(`div`,{className:l===`full`?`empty-acts`:`done-acts`,children:o&&(0,S.jsx)(`button`,{type:`button`,className:l===`full`?`btn btn-primary`:`btn btn-primary btn-sm`,onClick:o,children:`Finish review`})});return l===`docked`?(0,S.jsxs)(`div`,{className:`done-card`,role:`status`,children:[(0,S.jsxs)(`div`,{className:`done-card-row`,children:[(0,S.jsx)(gu,{}),(0,S.jsxs)(`span`,{className:`done-said`,children:[(0,S.jsx)(`span`,{className:`done-head`,children:f}),m]}),_,c&&(0,S.jsx)(`button`,{type:`button`,className:`done-close`,"data-tip":`Dismiss`,"aria-label":`Dismiss`,onClick:c,children:(0,S.jsx)(U,{name:`x`,size:`sm`})})]}),g]}):(0,S.jsxs)(`div`,{className:`pane-done`,children:[(0,S.jsx)(gu,{drawn:!0}),(0,S.jsx)(`h2`,{children:f}),h,g,_]})}var hu=[0,1,2,3,4,5,6,7];function gu({drawn:e=!1}){return(0,S.jsxs)(`span`,{className:`done-seal${e?` done-seal-drawn`:``}`,"aria-hidden":`true`,children:[e&&(0,S.jsx)(`span`,{className:`done-spark`,children:hu.map(e=>(0,S.jsx)(`i`,{},e))}),e?(0,S.jsx)(`svg`,{className:`done-tick`,viewBox:`0 0 24 24`,width:`26`,height:`26`,"aria-hidden":`true`,children:(0,S.jsx)(`path`,{d:`M5 12.5 L10 17.5 L19 7`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`})}):(0,S.jsx)(U,{name:`check`,size:`md`})]})}function _u({sha:e,subject:t,threads:n,onClear:r,onDismiss:i,shape:a}){let[o,s]=(0,x.useState)(!1),[c,l]=(0,x.useState)(!1),u=fs(),d=u&&u.state!==`open`?u:null,f=()=>{s(!0),l(!1),r().catch(()=>{s(!1),l(!0)})},p=(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`landed-sha`,children:e.slice(0,7)}),t!==``&&(0,S.jsxs)(`span`,{className:`landed-subject`,children:[` “`,t,`”`]})]}),m=n===0?`its review record`:`its ${n===1?`thread`:`${n} threads`} and guide`,h=o?`Clearing…`:n===0?d?`Clear the review`:`Start fresh`:d?`Clear ${n===1?`the thread`:`${n} threads`}`:`Start fresh: clear ${n===1?`the thread`:`${n} threads`}`,g=d&&(d.state===`merged`?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`b`,{children:`Merged`}),` as `,(0,S.jsx)(`span`,{className:`landed-sha`,children:e.slice(0,7)}),`. The diff is what shipped, and comments still post to GitHub.`]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`b`,{children:`Closed`}),` without merging. The diff stays to read, and comments still post to GitHub.`]})),_=c&&(0,S.jsx)(`p`,{className:`cov-note cov-note-error`,children:`Couldn't clear the review; the server may be down. Nothing was deleted; try again.`});return a===`docked`&&d?(0,S.jsxs)(`div`,{className:`landed-strip landed-strip-${d.state}`,role:`status`,children:[(0,S.jsx)(U,{name:`pr`,size:`sm`}),(0,S.jsx)(`span`,{className:`landed-strip-text`,children:g}),(0,S.jsx)(`button`,{type:`button`,className:`landed-strip-act`,disabled:o,title:`Deletes the threads and guide; Diffo drops the checkout when the server exits`,onClick:f,children:h}),(0,S.jsx)(`button`,{type:`button`,className:`done-close`,"data-tip":`Keep them`,"aria-label":`Keep the review as it is`,onClick:i,children:(0,S.jsx)(U,{name:`x`,size:`sm`})}),c&&(0,S.jsx)(`span`,{className:`landed-strip-err`,children:`Couldn't clear; nothing was deleted.`})]}):a===`docked`?(0,S.jsxs)(`div`,{className:`landed-card`,role:`status`,children:[(0,S.jsx)(`span`,{className:`landed-seal`,"aria-hidden":`true`,children:(0,S.jsx)(U,{name:`check`,size:`md`})}),(0,S.jsxs)(`span`,{className:`landed-said`,children:[`The previous review landed in `,p,`; `,m,` `,n===0?`is`:`are`,` still here, under this new changeset.`]}),(0,S.jsx)(`div`,{className:`landed-acts`,children:(0,S.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,disabled:o,onClick:f,children:h})}),(0,S.jsx)(`button`,{type:`button`,className:`done-close`,"data-tip":`Keep them`,"aria-label":`Keep the previous review's threads`,onClick:i,children:(0,S.jsx)(U,{name:`x`,size:`sm`})})]}):(0,S.jsxs)(`div`,{className:`empty-state landed-full`,children:[(0,S.jsx)(U,{name:`check`,size:`lg`}),g?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`h2`,{children:[`This pull request `,d.state===`merged`?`merged`:`closed`]}),(0,S.jsxs)(`p`,{children:[g,` Clear `,m,` when you are done, and Diffo drops the checkout.`]})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`h2`,{children:`This review landed`}),(0,S.jsxs)(`p`,{children:[`Commit `,p,` took the whole changeset;`,` `,n===0?`${m} belongs`:`${m} belong`,` to that round. Clear the slate and the next changeset starts its own review.`]})]}),(0,S.jsxs)(`div`,{className:`empty-acts`,children:[(0,S.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:o,onClick:f,children:h}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:i,children:`Keep them`})]}),_]})}function vu({layer:e,filesShown:t,comments:n}){let r=e.summary?Fo(e.summary,e.knownPaths):null,[i,a]=(0,x.useState)(!1),[o,s]=(0,x.useState)(null),c=e.id===null?[]:n?.partition.byLayer.get(e.id)??[],l=e.id===null?null:{kind:`layer`,layerId:e.id,title:e.title},u=t=>{let n=Po(t.target);n&&(t.preventDefault(),e.onJump(n.path,n.line))},d=t===0,f=!!(e.decisions&&e.decisions.length>0&&e.onOpenDecision),p=r!==null||e.missing.length>0||d,m=n!==void 0&&l!==null;return(0,S.jsxs)(`section`,{className:`ch-head`,"aria-label":`${e.kicker}: ${e.title}`,children:[(0,S.jsxs)(`div`,{className:`ch-head-top`,children:[(0,S.jsx)(`div`,{className:`ch-head-kicker`,children:e.kicker}),m&&!i&&(0,S.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm ch-head-ask`,onClick:()=>a(!0),children:[(0,S.jsx)(U,{name:`chat`,size:`sm`}),`Comment on this layer`]})]}),(0,S.jsxs)(`h2`,{children:[e.title,e.mechanical&&(0,S.jsx)(`span`,{className:`ch-kind`,title:`changes no behaviour; files are folded, expand one to check`,children:`mechanical`})]}),(p||f)&&(0,S.jsxs)(`div`,{className:`ch-head-body`,children:[p&&(0,S.jsxs)(`div`,{className:`ch-head-about`,children:[r&&(0,S.jsx)(`div`,{onClick:u,children:(0,S.jsx)(pc,{text:r,className:`cmt-body markdown ch-summary`,paths:e.knownPaths})}),e.missing.length>0&&(0,S.jsxs)(`div`,{className:`ch-head-files`,children:[(0,S.jsx)(`span`,{className:`ch-head-missing`,children:`not in the changeset now:`}),e.missing.map(e=>(0,S.jsx)(`span`,{className:`ch-chip ch-chip-done`,title:`${e}, not in the changeset now`,children:e},e))]}),d&&e.listed===0&&(0,S.jsxs)(`div`,{className:`ch-head-empty`,children:[`Nothing this layer lists is in the changeset right now. Move on with`,` `,(0,S.jsx)(`span`,{className:`kbd`,children:`]`}),`.`]}),d&&e.listed>0&&e.hidden===e.listed&&(0,S.jsxs)(`div`,{className:`ch-head-empty`,children:[e.hidden===1?`The one file`:`All ${e.hidden} files`,` in this layer`,` `,e.hidden===1?`is a test`:`are tests`,`, hidden by `,(0,S.jsx)(`b`,{children:`Hide tests`}),` on the bar. Move on with `,(0,S.jsx)(`span`,{className:`kbd`,children:`]`}),`.`]})]}),f&&(0,S.jsx)(sl,{decisions:e.decisions,open:e.openDecision??null,onOpen:e.onOpenDecision,onJump:e.onJump,onComment:m?t=>{s({label:`decision`,text:e.decisions[t].decision.text}),a(!0)}:void 0})]}),m&&(c.length>0||i)&&(0,S.jsxs)(`div`,{className:`ch-head-threads`,children:[c.length>0&&(0,S.jsx)(Ic,{threads:c,actions:n.actions,showContext:!0,agentConnected:n.agentConnected,workingOn:n.workingOn,queuedOn:n.queuedOn,links:n.links}),i&&(0,S.jsx)(bc,{citing:o??void 0,title:`Comment on this layer`,placeholder:`Ask about this step, or say what should change in it…`,scope:{label:`layer “${e.title}”`,canWiden:!1},fixedAudience:`agent`,agentConnected:n.agentConnected,onSubmit:(e,t,r)=>{n.actions.create(l,e,r),a(!1),s(null)},onSend:(e,t,r)=>{n.actions.create(l,e,r).then(e=>n.actions.send(e.id)),a(!1),s(null)},onCancel:()=>{a(!1),s(null)}})]})]})}var yu={added:`added`,deleted:`deleted`,renamed:`renamed`};function bu({file:e,viewed:t,collapsed:n=!1,onToggle:r,commentCount:i=0,sinceCount:a=0,note:o,onComment:s,onToggleFileViewed:c}){let[l,u]=(0,x.useState)(!1),[d,f]=(0,x.useState)(!1),p=(0,x.useRef)(void 0);(0,x.useEffect)(()=>()=>clearTimeout(p.current),[]);let m=0,h=0;for(let t of e.hunks)for(let e of t.lines)e.kind===`add`?m++:e.kind===`del`&&h++;let g=po(e,t),_=e.path.lastIndexOf(`/`),v=yu[e.status],y=e=>e.stopPropagation();return(0,S.jsxs)(`div`,{className:`file-header`,onClick:r,children:[(0,S.jsx)(`button`,{type:`button`,className:`file-chevron chevron${n?` chevron-shut`:``}`,"aria-expanded":!n,"data-tip":`${n?`Expand`:`Collapse`} this file`,"aria-label":`${n?`Expand`:`Collapse`} ${e.path}`,children:(0,S.jsx)(U,{name:`chev`})}),(0,S.jsxs)(`span`,{className:`file-path`,children:[e.status===`renamed`&&e.oldPath&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`file-oldpath`,children:e.oldPath}),` → `]}),_!==-1&&(0,S.jsx)(`span`,{className:`file-dir`,children:(0,S.jsx)(`bdi`,{children:e.path.slice(0,_+1)})}),(0,S.jsx)(`span`,{className:`file-base`,children:e.path.slice(_+1)})]}),v&&(0,S.jsx)(`span`,{className:`file-status file-status-${e.status}`,children:v}),a>0&&(0,S.jsxs)(`span`,{className:`file-since`,title:`since your last review; reading it settles it`,children:[`the agent changed`,` `,a===e.hunks.length?`this`:`${a} ${a===1?`hunk`:`hunks`}`]}),o&&(0,S.jsx)(`span`,{className:`ch-file-note`,title:o,children:o}),(0,S.jsx)(`button`,{type:`button`,className:`ghb file-copy`,"data-tip":l?`Copied`:`Copy path`,"aria-label":`Copy path`,onClick:t=>{y(t),Ct(e.path).then(()=>{u(!0),clearTimeout(p.current),p.current=setTimeout(()=>u(!1),1500)})},children:(0,S.jsx)(U,{name:l?`check`:`copy`,size:`sm`})}),(0,S.jsx)(`span`,{className:`grow`}),(m>0||h>0)&&(0,S.jsxs)(`span`,{className:`dstat`,children:[m>0&&(0,S.jsxs)(`span`,{className:`stat-add`,children:[`+`,m]}),h>0&&(0,S.jsxs)(`span`,{className:`stat-del`,children:[`−`,h]})]}),lu(e)&&(0,S.jsxs)(`button`,{type:`button`,className:`file-preview-btn`,title:`Read this file rendered`,"aria-label":`Preview ${e.path} rendered`,onClick:e=>{y(e),f(!0)},children:[(0,S.jsx)(U,{name:`book`,size:`sm`}),`Preview`]}),c&&(0,S.jsxs)(`button`,{type:`button`,className:`file-viewed-toggle`,"aria-pressed":g,title:`mark this whole file read`,onClick:e=>{y(e),c()},children:[(0,S.jsx)(Io,{state:g}),`Viewed`]}),s&&i>0&&(0,S.jsxs)(`button`,{type:`button`,className:`ghb file-comment-btn`,title:`${i} ${i===1?`thread`:`threads`} on this file`,"aria-label":`Comment on this file`,onClick:e=>{y(e),s()},children:[(0,S.jsx)(U,{name:`chat`,size:`sm`}),(0,S.jsx)(`span`,{className:`ghb-badge`,children:i})]}),(0,S.jsx)(`span`,{onClick:y,children:(0,S.jsx)(Va,{label:`More file actions`,triggerClassName:`ghb`,children:t=>(0,S.jsxs)(S.Fragment,{children:[s&&(0,S.jsx)(Ha,{icon:`chat`,onClick:()=>{t(),s()},children:`Comment on this file`}),(0,S.jsx)(Ha,{icon:`copy`,onClick:()=>{t(),Ct(e.path)},children:`Copy path`}),(0,S.jsx)(Ha,{icon:`fold`,kbd:`o`,onClick:()=>{t(),r?.()},children:n?`Expand file`:`Collapse file`})]})})}),d&&(0,S.jsx)(`span`,{onClick:y,children:(0,S.jsx)(uu,{path:e.path,onClose:()=>f(!1)})})]})}function xu(e){return{fingerprint:e,headLines:null,exp:new Map,failed:new Set}}function Su(e){let t=(0,x.useMemo)(()=>el(e),[e]),n=(0,x.useMemo)(()=>`${e.newLineCount??``}#${e.hunks.map(e=>e.id).join(`
89
89
  `)}`,[e]),[r,i]=(0,x.useState)(()=>xu(n));r.fingerprint!==n&&i(xu(n));let a=r.fingerprint===n?r:xu(n),o=async(t,r)=>{let o=a.headLines;if(o===null)try{let t=await fetch(`/api/file?path=${encodeURIComponent(e.path)}&side=head`);if(!t.ok)throw Error(`/api/file → ${t.status}`);let n=await t.text();o=n.endsWith(`
90
90
  `)?n.slice(0,-1).split(`
91
91
  `):n.split(`
92
- `)}catch{i(e=>e.fingerprint===n?{...e,failed:new Set(e.failed).add(t.key)}:e);return}let s=a.exp.get(t.key)??Gc,c=r===`all`?{fromTop:tl(t),fromBottom:0}:r===`down`?{...s,fromTop:s.fromTop+20}:{...s,fromBottom:s.fromBottom+20},l=il(o,t,s),u=il(o,t,c),d=o;if(u.top.length+u.bottom.length<=l.top.length+l.bottom.length){i(e=>e.fingerprint===n?{...e,headLines:d,failed:new Set(e.failed).add(t.key)}:e);return}i(e=>{if(e.fingerprint!==n)return e;let r=new Set(e.failed);return r.delete(t.key),{...e,headLines:d,exp:new Map(e.exp).set(t.key,c),failed:r}})},s=e=>i(t=>{if(t.fingerprint!==n)return t;let r=new Map(t.exp);r.delete(e.key);let i=new Set(t.failed);return i.delete(e.key),{...t,exp:r,failed:i}}),c=(0,x.useMemo)(()=>{let e=new Map;if(a.headLines===null)return e;for(let n of t){let t=a.exp.get(n.key);t&&e.set(n.key,il(a.headLines,n,t))}return e},[t,a]);return{gaps:t,visible:c,controlsFor:e=>{let t=a.exp.get(e.key)??Gc;return{remaining:nl(e,t),canUp:e.below!==null,canDown:e.above!==null,expanded:t.fromTop+t.fromBottom>0,merged:c.get(e.key)?.merged??!1,failed:a.failed.has(e.key),onUp:()=>void o(e,`up`),onDown:()=>void o(e,`down`),onAll:()=>void o(e,`all`),onCollapse:()=>s(e)}}}}function Cu({file:e,delta:t,sinceReview:n,handlers:r,composerOpen:i=!1,onCloseComposer:a,stub:o=null,onLoadDiff:s}){let c=e.status!==`deleted`&&e.kind===`text`,{gaps:l,visible:u,controlsFor:d}=Su(e),f=r.comments,p=f?.partition.byFile.get(e.path)??[],m=e.path.slice(e.path.lastIndexOf(`/`)+1),h=t=>t?{kind:`changeset`}:{kind:`file`,path:e.path},g=f&&(p.length>0||i)&&(0,S.jsxs)(`div`,{className:`file-threads`,children:[(0,S.jsx)(Ic,{threads:p,actions:f.actions,showContext:!0,agentConnected:f.agentConnected,workingOn:f.workingOn,queuedOn:f.queuedOn}),i&&(0,S.jsx)(bc,{title:`Comment on ${m}`,placeholder:`Leave a comment…`,scope:{label:m,canWiden:!0},agentConnected:f.agentConnected,onSubmit:(e,t,n,r)=>{r?f.actions.create(h(t),e,n,{audience:r}):f.actions.create(h(t),e,n),a?.()},onSend:(e,t,n)=>{f.actions.create(h(t),e,n).then(e=>f.actions.send(e.id)),a?.()},onCancel:()=>a?.()})]});if(o!==null)return(0,S.jsxs)(S.Fragment,{children:[g,(0,S.jsxs)(`div`,{className:`file-stub file-stub-large`,children:[(0,S.jsx)(`span`,{children:o===`generated`?`Generated file, not rendered by default.`:`Large diff (${Uc(e)} changed lines), not rendered by default.`}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:s,children:`Load diff`})]})]});if(e.kind===`image`&&e.hunks.length===0)return(0,S.jsxs)(S.Fragment,{children:[g,(0,S.jsx)(cu,{file:e})]});if(e.kind===`binary`)return(0,S.jsxs)(S.Fragment,{children:[g,(0,S.jsx)(`div`,{className:`file-stub`,children:`binary file changed`})]});if(e.hunks.length===0)return(0,S.jsxs)(S.Fragment,{children:[g,(0,S.jsx)(`div`,{className:`file-stub`,children:e.status===`renamed`?`renamed, no content changes`:`no content changes`})]});let _=po(e,r.viewed),v=new Map,y=new Map;for(let e of l)e.below!==null&&v.set(e.below,e),e.above!==null&&y.set(e.above,e);let b=l.find(e=>e.below===null);return(0,S.jsxs)(S.Fragment,{children:[g,e.kind===`image`&&(0,S.jsx)(cu,{file:e}),e.hunks.map((e,i)=>{let a=c?v.get(i):void 0,o=c?y.get(i):void 0;return(0,S.jsx)(ou,{hunk:e,fresh:t.freshHunkIds.has(e.id),changedSinceReview:n?.has(e.id)??!1,changedSinceViewed:t.changedViewedHunkIds.has(e.id),viewed:_,selected:r.selectedId===e.id,onSelect:r.onSelect,viewMode:r.viewMode??`unified`,linesAbove:a&&u.get(a.key)?.bottom,linesBelow:o&&u.get(o.key)?.top,gapAbove:a?d(a):null,threads:f?.partition.byHunk.get(e.id),reviewActions:f?.actions,agentConnected:f?.agentConnected,workingOn:f?.workingOn,queuedOn:f?.queuedOn,composeRequested:f?.composeHunkId===e.id,onComposeHandled:f?.onComposeHandled},e.id)}),c&&b&&(0,S.jsx)(Yl,{gap:d(b)})]})}function wu({files:e,delta:t=al,sinceReview:n,hasMore:r=!1,onLoadMore:i,controls:a,landed:o,layer:s,overview:c=!1,...l}){let[u,d]=(0,x.useState)(null),[f,p]=(0,x.useState)(!1),[m,h]=(0,x.useState)(new Set),g=l.selectedId;(0,x.useEffect)(()=>{if(!g)return;let t=e.find(e=>e.hunks.some(e=>e.id===g));t&&Wc(t)!==null&&h(e=>e.has(t.path)?e:new Set(e).add(t.path))},[g,e]);let _=(0,x.useRef)(null),v=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(!r||!i)return;if(typeof IntersectionObserver>`u`){i();return}let e=v.current;if(!e)return;let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&i()},{root:_.current,rootMargin:`1200px 0px`});return t.observe(e),()=>t.disconnect()},[r,i,e.length]);let y=(0,x.useRef)({files:e,controls:a,viewed:l.viewed});y.current={files:e,controls:a,viewed:l.viewed};let b=(0,x.useRef)(0);(0,x.useEffect)(()=>{let e=_.current;if(!e)return;let t=0,n=()=>{t=0;let{files:n,controls:r,viewed:i}=y.current;if(!r?.hideReviewed||r.pinned.size===0)return;let a=(e.querySelector(`.pane-bar`)??e).getBoundingClientRect().bottom;for(let e of n){if(!r.pinned.has(e.path)||!po(e,i))continue;let t=document.getElementById(zo(e.path));if(!t)continue;let n=t.getBoundingClientRect();n.bottom>=a||(b.current+=n.height+(parseFloat(getComputedStyle(t).marginBottom)||0),r.onSweep(e.path))}},r=()=>{t!==0&&cancelAnimationFrame(t),t=requestAnimationFrame(n)};return e.addEventListener(`scroll`,r,{passive:!0}),()=>{e.removeEventListener(`scroll`,r),t!==0&&cancelAnimationFrame(t)}},[]),(0,x.useLayoutEffect)(()=>{let e=_.current;e&&b.current!==0&&(e.scrollTop-=b.current,b.current=0)});let C=l.comments?.composeFilePath??null;(0,x.useEffect)(()=>{C&&(l.collapsed?.has(C)&&l.onToggleCollapsed?.(C),d(C),l.comments?.onComposeFileHandled?.())},[C]);let[w,T]=(0,x.useState)(null),E=w??s===void 0,D=T,O=l.comments,k=O?.revealNotesTick??0;(0,x.useEffect)(()=>{k>0&&D(!0)},[k]);let A=c||E||O?.changesetComposerOpen===!0,j=c||s===void 0,[M,N]=(0,x.useState)(!1),P=O?.revealPastTick??0;(0,x.useEffect)(()=>{P>0&&N(!0)},[P]);let F=fs(),I=O?.partition.changeset.length??0,ee=F?.viewer.login??null,te=O?.partition.changeset,{lead:ne,others:L}=(0,x.useMemo)(()=>{let e=te??[];if(!F)return{lead:e,others:[]};let t=e=>e.github?.kind===`description`||!it(e)||Cs(e,ee);return{lead:e.filter(t),others:e.filter(e=>!t(e))}},[te,F,ee]),[re,ie]=(0,x.useState)(!1),ae=O?.revealThreadId??null;(0,x.useEffect)(()=>{k>0&&ae!==null&&L.some(e=>e.id===ae)&&ie(!0)},[k,ae,L]);let oe=O&&j&&(I>0||O.changesetComposerOpen||c)&&(0,S.jsxs)(`section`,{className:`changeset-strip`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`strip-head`,onClick:()=>D(!E),"aria-expanded":A,children:[(0,S.jsx)(`span`,{className:`file-chevron chevron${A?``:` chevron-shut`}`,children:(0,S.jsx)(U,{name:`chev`})}),F?`On the pull request`:`On the changeset`,(0,S.jsx)(`span`,{className:`strip-n`,children:I})]}),A&&(0,S.jsxs)(`div`,{className:`strip-body`,children:[(0,S.jsx)(Ic,{threads:ne,actions:O.actions,showContext:!0,agentConnected:O.agentConnected,workingOn:O.workingOn,queuedOn:O.queuedOn,links:O.links}),L.length>0&&(0,S.jsx)(`button`,{type:`button`,className:`strip-more`,"aria-expanded":re,onClick:()=>ie(!re),children:re?`Only mine`:`${L.length} more from others`}),re&&L.length>0&&(0,S.jsx)(Ic,{threads:L,actions:O.actions,showContext:!0,agentConnected:O.agentConnected,workingOn:O.workingOn,queuedOn:O.queuedOn,links:O.links}),O.changesetComposerOpen?(0,S.jsx)(bc,{title:`Note on the whole changeset`,placeholder:`Leave a note…`,scope:{label:`the whole changeset`,canWiden:!1},agentConnected:O.agentConnected,onSubmit:(e,t,n,r)=>{r?O.actions.create({kind:`changeset`},e,n,{audience:r}):O.actions.create({kind:`changeset`},e,n),O.onCloseChangesetComposer?.()},onSend:(e,t,n)=>{O.actions.create({kind:`changeset`},e,n).then(e=>O.actions.send(e.id)),O.onCloseChangesetComposer?.()},onCancel:()=>O.onCloseChangesetComposer?.()}):O.onOpenChangesetComposer&&(0,S.jsx)(`button`,{type:`button`,className:`strip-add`,onClick:O.onOpenChangesetComposer,children:F?`+ Comment on the pull request`:`+ Note on the changeset`})]})]}),se=O?.past??[],ce=se.filter(e=>e.github?.outdated===!0).length,le=se.filter(e=>e.anchor.kind===`layer`).length,ue=le===se.length?`The layer ${se.length===1?`this hangs`:`these hang`} off left the outline: the agent re-posted without ${se.length===1?`its`:`their`} title.`:ce===se.length?`${se.length===1?`This one is`:`These are`} outdated on GitHub: the line ${se.length===1?`it hangs`:`they hang`} off left the diff, though the file is still in it.`:ce>0?`The file or change these hang off is no longer in the diff: reverted, deleted, or stashed; ${ce} ${ce===1?`is`:`are`} outdated on GitHub instead, the line left the diff.`:`The file or change these hang off is no longer in the diff: reverted, deleted, or stashed.`,de=O&&se.length>0&&(0,S.jsxs)(`section`,{className:`file-section past-threads`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`file-header notes-header`,onClick:()=>N(e=>!e),"aria-expanded":M,children:[(0,S.jsx)(`span`,{className:`file-chevron chevron${M?``:` chevron-shut`}`,children:(0,S.jsx)(U,{name:`chev`})}),(0,S.jsxs)(`span`,{className:`file-path`,children:[se.length===1?`1 thread`:`${se.length} threads`,` whose`,` `,le===se.length?`layer left the outline`:`code left the changeset`]})]}),M&&(0,S.jsxs)(`div`,{className:`file-threads`,children:[(0,S.jsxs)(`div`,{className:`past-hint`,children:[ue,` The conversation is intact`,le===se.length?`.`:`, and the snapshot inside each one is the code you commented on.`]}),(0,S.jsx)(Ic,{threads:se,actions:O.actions,showContext:!0,gone:!0,agentConnected:O.agentConnected,workingOn:O.workingOn,queuedOn:O.queuedOn})]})]}),R=a?.total??0,z=e.length===0&&R===0,B=e.length===0&&R>0,fe=a!==void 0&&a.scopeTotal>0&&a.scopeLeft===0;(0,x.useEffect)(()=>{fe&&p(!1)},[fe]);let pe=(a?.hiddenTests??0)+(a?.hiddenReviewed??0)+(a?.hiddenUnchanged??0)+(a?.hiddenQuery??0),me=a&&(0,S.jsx)(mu,{read:a.total-a.left,total:a.total,excludedTests:a.excludedTests,excludedUnchanged:a.excludedUnchanged,stats:a.stats,unsent:a.unsent,onFinish:a.onFinish,onIncludeExcluded:a.onIncludeExcluded,onDismiss:()=>p(!0),shape:B?`full`:`docked`}),he=c?null:z?o?(0,S.jsx)(_u,{...o,shape:`full`}):(0,S.jsxs)(`div`,{className:`empty-state`,children:[(0,S.jsx)(U,{name:`book`,size:`lg`}),(0,S.jsx)(`h2`,{children:`Nothing to review`}),(0,S.jsx)(`p`,{children:`The working tree is clean. Diffo is watching; start your agent and changes appear here as they land.`})]}):s&&e.length===0?(0,S.jsx)(vu,{layer:s,filesShown:0,comments:O}):B&&fe?me:B&&a?(0,S.jsxs)(`div`,{className:`empty-state`,children:[(0,S.jsx)(U,{name:`filter`,size:`lg`}),(0,S.jsxs)(`h2`,{children:[a.left,` `,a.left===1?`file`:`files`,` still to review`]}),(0,S.jsx)(`p`,{children:a.hiddenQuery===0?`They're hidden by the switches on the bar above.`:a.hiddenTests+a.hiddenReviewed+a.hiddenUnchanged===0?`None of them match “${a.query.trim()}”.`:`They're hidden by “${a.query.trim()}” and the switches on the bar above.`}),(0,S.jsx)(`div`,{className:`empty-acts`,children:(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:a.onShowAll,children:`Show all files`})})]}):(0,S.jsxs)(S.Fragment,{children:[s&&(0,S.jsx)(vu,{layer:s,filesShown:e.length,comments:O}),e.map(e=>{let r=l.collapsed?.has(e.path)??!1,i=O?.partition.byFile.get(e.path)?.length??0,a=O===void 0?0:e.hunks.reduce((e,t)=>e+(O.partition.byHunk.get(t.id)?.length??0),0),o=g!=null&&e.hunks.some(e=>e.id===g),c=m.has(e.path)||o||a>0?null:Wc(e),f=n===void 0?0:e.hunks.reduce((e,t)=>e+ +!!n.has(t.id),0);return(0,S.jsxs)(`section`,{id:zo(e.path),className:`file-section${r?` file-section-collapsed`:``}`,children:[(0,S.jsx)(bu,{file:e,viewed:l.viewed,collapsed:r,onToggle:()=>l.onToggleCollapsed?.(e.path),commentCount:i+a,sinceCount:f,note:s?.notes.get(e.path),onToggleFileViewed:l.onToggleFileViewed?()=>l.onToggleFileViewed(e.path):void 0,onComment:O?()=>{r&&l.onToggleCollapsed?.(e.path),d(t=>t===e.path?null:e.path)}:void 0}),!r&&(0,S.jsx)(Cu,{file:e,delta:t,sinceReview:n,handlers:l,composerOpen:u===e.path,onCloseComposer:()=>d(null),stub:c,onLoadDiff:()=>h(t=>new Set(t).add(e.path))})]},e.path)}),r&&(0,S.jsxs)(`div`,{ref:v,className:`load-more`,"aria-hidden":`true`,children:[(0,S.jsx)(`div`,{className:`shimmer`}),(0,S.jsx)(`div`,{className:`shimmer shimmer-short`})]}),a&&pe>0&&(0,S.jsxs)(`div`,{className:`pane-hidden`,children:[(0,S.jsxs)(`span`,{className:`pane-hidden-said`,children:[(0,S.jsx)(U,{name:`eye-off`,size:`sm`}),[a.hiddenQuery>0?`${a.hiddenQuery} not matching “${a.query.trim()}”`:null,a.hiddenUnchanged>0?`${a.hiddenUnchanged} unchanged`:null,a.hiddenTests>0?`${a.hiddenTests} test${a.hiddenTests===1?``:`s`}`:null,a.hiddenReviewed>0?`${a.hiddenReviewed} reviewed`:null].filter(Boolean).join(`, `),` `,`hidden`]}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:a.onShowAll,children:`Show all files`})]})]});return(0,S.jsxs)(`div`,{className:`reading-pane${a?` reading-pane-barred`:``}`,ref:_,children:[a&&(0,S.jsx)(du,{navHidden:a.navHidden,onToggleNav:a.onToggleNav,left:a.left,total:a.total,hunksRead:a.hunksRead,hunksTotal:a.hunksTotal,hunkAt:a.hunkAt,hunkCount:a.hunkCount,query:a.query,onClearQuery:a.onClearQuery,hideReviewed:a.hideReviewed,onHideReviewed:a.onHideReviewed,hideTests:a.hideTests,onHideTests:a.onHideTests,testCount:a.testCount,onlyChanged:a.onlyChanged,onOnlyChanged:a.onOnlyChanged,changedCount:a.changedCount,viewMode:a.viewMode,onSetViewMode:a.onSetViewMode,allCollapsed:a.allCollapsed,onToggleCollapseAll:a.onToggleCollapseAll,stats:a.stats,layer:a.layer}),(0,S.jsxs)(`div`,{className:`reading-col`,children:[o&&!z&&(0,S.jsx)(_u,{...o,shape:`docked`}),oe,de,he]}),fe&&!B&&!f&&me]})}var Tu=[{name:`Move`,keys:[[`j`,`Next hunk`],[`k`,`Previous hunk`],[`J`,`Next file`],[`K`,`Previous file`],[`n`,`Next unreviewed file`],[`]`,`Next layer`],[`[`,`Previous layer`],[`.`,`Next decision in this layer`],[`/`,`Filter files`]]},{name:`Read`,keys:[[`v`,`Mark this file reviewed`],[`h`,`Hide reviewed files`],[`u`,`Unified / split`],[`o`,`Collapse / expand file`],[`b`,`Show / hide the file list`]]},{name:`Comment`,keys:[[`c`,`Comment on the clicked line, else this hunk`],[`drag ↓`,`Comment on a range of lines`],[`⇧ click`,`Move the range’s edge to a line`],[`⌘↵`,`Add the comment`],[`esc`,`Close / cancel`],[`?`,`This sheet`]]}];function Eu({onClose:e}){return(0,S.jsx)(At,{title:`Shortcuts`,onClose:e,children:(0,S.jsx)(`div`,{className:`keys`,children:Tu.map(e=>(0,S.jsxs)(`div`,{className:`keys-group`,children:[(0,S.jsx)(`div`,{className:`keys-name`,children:e.name}),e.keys.map(([e,t])=>(0,S.jsxs)(`div`,{className:`keys-row`,children:[(0,S.jsx)(`span`,{className:`kbd`,children:e}),` `,t]},e))]},e.name))})})}var Du={COMMENT:`Commented`,APPROVE:`Approved`,REQUEST_CHANGES:`Changes requested`};function Ou({coverage:e,presence:t,onFinish:n,onInvite:r,onClose:i}){let a=fs(),o=xt(!0,e),s=(0,x.useRef)(null),[c,l]=(0,x.useState)(``),[u,d]=(0,x.useState)(`write`),[f,p]=(0,x.useState)(`COMMENT`),[m,h]=(0,x.useState)(!1),[g,_]=(0,x.useState)(!1),[v,y]=(0,x.useState)(null),[b,C]=(0,x.useState)(null),[w,T]=(0,x.useState)(!1),E=t!==`waiting`,D=o.data?.public,O=o.data?.outgoing??[],k=D?D.drafts.length+D.replies.length+D.resolves.length:0,A=a!==null&&a.state!==`open`,j=k>0||f!==`COMMENT`||c.trim()!==``||o.isError,M=()=>{j&&!m&&(_(!1),y(null),h(!0),n(!0,{note:c,event:f}).then(({delivered:e,public:t})=>{if(t?.failed){y(t.failed),o.refetch();return}C(t??{posted:0,resolved:0,submitted:!1,reviewId:null}),T(e)}).catch(()=>_(!0)).finally(()=>h(!1)))},N=[[`COMMENT`,`Comment`,`Submit general feedback without explicit approval.`],[`APPROVE`,`Approve`,`Submit feedback and approve merging these changes.`],[`REQUEST_CHANGES`,`Request changes`,`Submit feedback suggesting changes.`]],P=A?`${a.state===`merged`?`Merged`:`Closed`} already: GitHub takes comments, not verdicts.`:D&&!D.canApprove?`Your own pull request: GitHub does not let you approve or block it.`:null;(0,x.useEffect)(()=>{f!==`COMMENT`&&P!==null&&p(`COMMENT`)},[f,P]);let F=O.length>0?`${O.length} private ${O.length===1?`thread`:`threads`} and your coverage`:`your coverage`,I=b?(0,S.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:i,children:`Done`}):(0,S.jsxs)(S.Fragment,{children:[o.data&&(0,S.jsxs)(`span`,{className:`sub-agent${E?``:` sub-agent-off`}`,children:[(0,S.jsx)(U,{name:E?`lock`:`alert`,size:`sm`}),(0,S.jsx)(`span`,{className:`sub-agent-text`,children:E?(0,S.jsxs)(S.Fragment,{children:[`Also, privately: `,F,` go to your agent`]}):(0,S.jsxs)(S.Fragment,{children:[`No agent attached: `,F,` wait for one.`,` `,(0,S.jsx)(`button`,{type:`button`,className:`fin-link`,onClick:r,children:`Invite one`})]})})]}),(0,S.jsx)(`span`,{className:`grow`}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:m,onClick:i,children:`Cancel`}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-gh${m?` btn-busy`:``}`,disabled:!j||m,"aria-busy":m,title:j?`post this review on GitHub, #${a?.number??``} (⌘↵)`:`nothing for GitHub yet: write a comment, pick a verdict, or draft a review comment`,onClick:M,children:m?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`spin`,"aria-hidden":`true`}),` Submitting to GitHub`]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(U,{name:`globe`,size:`sm`}),` Submit to GitHub `,(0,S.jsx)(`kbd`,{className:`sub-kbd`,children:`⌘↵`})]})})]});return(0,S.jsxs)(At,{title:b?`Review submitted to GitHub`:`Submit review to GitHub`,wide:!0,className:`sub-modal`,onClose:i,footer:I,children:[a&&(0,S.jsxs)(`div`,{className:`sub-where`,children:[(0,S.jsx)(U,{name:`pr`,size:`sm`}),(0,S.jsxs)(`span`,{className:`sub-where-repo`,children:[`one review on `,a.owner,`/`,a.repo,` #`,a.number]}),(0,S.jsx)(`span`,{className:`sub-where-title`,children:a.title})]}),!b&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`sub-editor`,children:[(0,S.jsxs)(`div`,{className:`sub-editor-bar`,children:[(0,S.jsx)(`div`,{className:`cbox-tabs sub-tabs`,role:`tablist`,children:[`write`,`preview`].map(e=>(0,S.jsx)(`button`,{type:`button`,role:`tab`,className:`cbox-tab`,"aria-selected":u===e,onClick:()=>d(e),children:e===`write`?`Write`:`Preview`},e))}),u===`write`&&(0,S.jsx)(`div`,{className:`sub-tools`,children:gc.map((e,t)=>e===`sep`?(0,S.jsx)(`span`,{className:`cbox-mdsep`},t):(0,S.jsx)(`button`,{type:`button`,className:`cbox-mdb`,"data-tip":e.label,"aria-label":e.label,onClick:()=>s.current&&yc(s.current,e,l),children:(0,S.jsx)(U,{name:e.icon,size:`sm`})},t))})]}),u===`write`?(0,S.jsx)(`textarea`,{ref:s,autoFocus:!0,className:`sub-body`,placeholder:`Leave a comment`,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),M())}}):c.trim()?(0,S.jsx)(pc,{className:`sub-preview markdown`,text:c}):(0,S.jsx)(`div`,{className:`sub-preview sub-preview-empty`,children:`Nothing to preview`})]}),(0,S.jsx)(`div`,{className:`sub-verdicts`,role:`radiogroup`,"aria-label":`Your verdict`,children:N.map(([e,t,n])=>{let r=e!==`COMMENT`&&P!==null;return(0,S.jsxs)(`label`,{className:`sub-verdict${f===e?` sub-verdict-on`:``}${r?` sub-verdict-off`:``}`,children:[(0,S.jsx)(`input`,{type:`radio`,name:`verdict`,value:e,checked:f===e,disabled:r,onChange:()=>p(e)}),(0,S.jsxs)(`span`,{className:`sub-verdict-text`,children:[(0,S.jsx)(`b`,{children:t}),(0,S.jsx)(`small`,{className:r?`sub-verdict-why`:void 0,children:r?P:n})]})]},e)})}),(0,S.jsxs)(`div`,{className:`fin-sect`,children:[(0,S.jsxs)(`div`,{className:`fin-sect-h`,children:[(0,S.jsx)(`span`,{className:`fin-sect-label`,children:`Pending`}),D&&(0,S.jsx)(`span`,{className:`fin-sect-n`,children:k}),(0,S.jsx)(`span`,{className:`fin-sect-why`,children:o.isLoading?`· loading`:o.error||!D?`· could not load what is pending; the review still submits`:k>0?`· post to GitHub with this review; nothing has posted yet`:`· nothing drafted; a comment above still submits a review to GitHub`})]}),D&&k>0&&(0,S.jsxs)(`ul`,{className:`sub-pending`,children:[D.drafts.map(e=>(0,S.jsxs)(`li`,{className:`sub-pending-row`,children:[(0,S.jsxs)(`div`,{className:`sub-pending-at`,children:[(0,S.jsx)(`span`,{className:`sub-pending-kind`,children:e.conversation?`comment`:`review comment`}),(0,S.jsx)(`span`,{className:`sub-pending-anchor`,children:e.anchor}),e.fromAgent&&(0,S.jsxs)(`span`,{className:`fin-row-note sub-pending-origin`,title:`your agent wrote the first version; it posts as yours`,children:[`from your agent`,e.fromAgent.edited&&`, edited`]}),e.downgraded&&(0,S.jsx)(`span`,{className:`fin-row-note`,title:`GitHub only takes comments on lines in its diff`,children:`line not in the diff; posts on the file`})]}),(0,S.jsx)(`div`,{className:`sub-pending-text`,children:e.text})]},e.id)),D.replies.map(e=>(0,S.jsxs)(`li`,{className:`sub-pending-row`,children:[(0,S.jsxs)(`div`,{className:`sub-pending-at`,children:[(0,S.jsx)(`span`,{className:`sub-pending-kind`,children:e.count===1?`reply`:`${e.count} replies`}),(0,S.jsx)(`span`,{className:`sub-pending-anchor`,children:e.anchor})]}),(0,S.jsx)(`div`,{className:`sub-pending-text`,children:e.text})]},e.id)),D.resolves.map(e=>(0,S.jsx)(`li`,{className:`sub-pending-row`,children:(0,S.jsxs)(`div`,{className:`sub-pending-at`,children:[(0,S.jsx)(`span`,{className:`sub-pending-kind`,children:e.resolve?`resolve`:`reopen`}),(0,S.jsx)(`span`,{className:`sub-pending-anchor`,children:e.anchor})]})},e.id))]}),D&&(D.undecidedSuggestions??0)>0&&(0,S.jsx)(`p`,{className:`sub-undecided`,role:`note`,children:D.undecidedSuggestions===1?`One suggested comment from your agent is still undecided. It stays private and never posts.`:`${D.undecidedSuggestions} suggested comments from your agent are still undecided. They stay private and never post.`})]})]}),b&&(0,S.jsxs)(`div`,{className:`sub-done`,children:[(0,S.jsxs)(`div`,{className:`sub-done-card`,children:[(0,S.jsx)(`span`,{className:`sub-done-mark`,"aria-hidden":`true`,children:(0,S.jsx)(U,{name:`check`,size:`md`})}),(0,S.jsxs)(`div`,{className:`sub-done-text`,children:[(0,S.jsx)(`b`,{children:b.submitted?Du[f]:`Review finished`}),(0,S.jsx)(`span`,{className:`sub-done-detail`,children:[b.posted>0&&`${b.posted} ${b.posted===1?`comment`:`comments`} posted`,b.resolved>0&&`${b.resolved} ${b.resolved===1?`thread`:`threads`} resolved`].filter(Boolean).join(` · `)||`on #${a?.number??``}`})]}),b.url&&(0,S.jsxs)(`a`,{className:`btn btn-sm btn-outline`,href:b.url,target:`_blank`,rel:`noreferrer`,children:[`Open on GitHub `,(0,S.jsx)(U,{name:`link`,size:`sm`})]})]}),(0,S.jsxs)(`p`,{className:`sub-done-agent`,children:[(0,S.jsx)(U,{name:`lock`,size:`sm`}),w?`Private threads and coverage went to your agent.`:`Private threads and coverage go to your agent on its next poll.`]})]}),v&&(0,S.jsxs)(`div`,{className:`warn`,children:[(0,S.jsx)(U,{name:`alert`,size:`sm`}),(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`b`,{children:[`GitHub stopped at `,v.step]}),`: `,v.message,`. What posted before it is recorded and will not post twice; nothing went to your agent. Fix the cause and submit again.`]})]}),g&&(0,S.jsx)(`p`,{className:`cov-note cov-note-error`,children:`Couldn't submit; the server may be down. Nothing was sent; try again.`})]})}var ku={showDelay:600,leaveGrace:500},Au=class{hooks;timing;armed=null;shown=null;showTimer;hideTimer;constructor(e,t=ku){this.hooks=e,this.timing=t}over(e){if(this.shown&&this.hooks.same(e,this.shown)){this.cancelHide();return}this.armed&&this.hooks.same(e,this.armed)||(this.shown&&this.leave(),this.cancelShow(),this.armed=e,this.showTimer=setTimeout(()=>{this.showTimer=void 0,this.armed=null,this.shown=e,this.hooks.show(e)},this.timing.showDelay))}inCard(){this.cancelHide(),this.cancelShow()}away(){this.cancelShow(),this.leave()}dismiss(){this.cancelShow(),this.cancelHide(),this.close()}get isShown(){return this.shown!==null}leave(){this.shown&&this.hideTimer===void 0&&(this.hideTimer=setTimeout(()=>{this.hideTimer=void 0,this.close()},this.timing.leaveGrace))}close(){this.shown&&(this.shown=null,this.hooks.hide())}cancelShow(){this.showTimer!==void 0&&clearTimeout(this.showTimer),this.showTimer=void 0,this.armed=null}cancelHide(){this.hideTimer!==void 0&&clearTimeout(this.hideTimer),this.hideTimer=void 0}},ju=/[A-Za-z_$][\w$]*/g;function Mu(e,t){ju.lastIndex=0;for(let n of e.matchAll(ju)){let e=n.index,r=e+n[0].length;if(t<e)return null;if(t<=r)return{word:n[0],start:e,end:r}}return null}var Nu=new Set(`abstract and as assert async await begin bool boolean break case catch chan char class const continue crate debugger decimal def default defer del delete do done double dyn elif else elsif end ensure enum esac except export extends extern fallthrough false fi final finally float fn for from func function global go goto if impl implements import in include instanceof int interface internal is lambda let local long loop match mod module move mut namespace native new nil nonlocal not null of or override package pass private protected pub public raise readonly ref require rescue return satisfies sealed select self short signed sizeof static struct super switch template then this throw throws trait transient true try type typedef typename typeof undefined union unless unsigned until use using var virtual void volatile where while with yield None True False Self`.split(` `));function Pu(e){return e.length>0&&!Nu.has(e)}function Fu(e,t){return t===`base`?e!==`add`:e!==`del`}function Iu(e){return e.replace(/[$\\]/g,`\\$&`)}function Lu(e,t,n){if(!t)return[];let r=RegExp(`(?<![\\w$])${Iu(t)}(?![\\w$])`),i=[];for(let t of e){if(t.kind!==`text`)continue;let e=[];for(let i of t.hunks)for(let a of i.lines){if(!Fu(a.kind,n))continue;let o=n===`base`?a.oldNo:a.newNo;if(o===null)continue;let s=r.exec(a.text);s&&e.push({path:t.path,hunkId:i.id,line:o,text:a.text,col:s.index})}e.length!==0&&(e.sort((e,t)=>e.line-t.line),i.push({path:t.path,usages:e}))}return i}function Ru(e){return e.reduce((e,t)=>e+t.usages.length,0)}var zu=`sym-occ`;function Bu({files:e,onJump:t}){let[n,r]=(0,x.useState)(null),i=(0,x.useRef)(null),a=(0,x.useRef)(()=>{}),o=(0,x.useMemo)(()=>{let t=new Map;for(let n of e)for(let e of n.hunks)t.set(e.id,n.path);return t},[e]),s=(0,x.useRef)(o);s.current=o,(0,x.useEffect)(()=>{let e=new Au({same:(e,t)=>e.cell===t.cell&&e.start===t.start&&e.word===t.word,show:e=>{Z(e.word,e.side),r(e)},hide:()=>{Q(),r(null)}}),t=e=>i.current!==null&&e instanceof Node&&i.current.contains(e),n=n=>{if(t(n.target)){e.inCard();return}let r=n.target instanceof Element?n.target:null,i=r?Xu(r,n.clientX,n.clientY,s.current):null;i?e.over(i):e.away()},o=()=>e.dismiss(),c=e=>{e.key===`Escape`&&o()},l=e=>{t(e.target)||o()},u=e=>{t(e.target)||o()};return a.current=o,document.addEventListener(`mousemove`,n,!0),document.addEventListener(`mousedown`,l,!0),document.addEventListener(`scroll`,u,!0),document.addEventListener(`keydown`,c,!0),window.addEventListener(`resize`,o),window.addEventListener(`blur`,o),()=>{o(),document.removeEventListener(`mousemove`,n,!0),document.removeEventListener(`mousedown`,l,!0),document.removeEventListener(`scroll`,u,!0),document.removeEventListener(`keydown`,c,!0),window.removeEventListener(`resize`,o),window.removeEventListener(`blur`,o)}},[]);let c=(0,x.useMemo)(()=>n?Lu(e,n.word,n.side):[],[e,n]);return(0,x.useLayoutEffect)(()=>{let e=i.current;if(!e||!n)return;let t=Yu(n.cell,n.start,n.end)?.getBoundingClientRect();if(!t)return;let r=e.offsetWidth,a=e.offsetHeight,o=Math.max(8,Math.min(t.left-10,window.innerWidth-r-8)),s=t.top-a-4,c=s>=8?s:Math.min(t.bottom+4,window.innerHeight-a-8);e.style.left=`${Math.round(o)}px`,e.style.top=`${Math.round(c)}px`,e.dataset.place=s>=8?`above`:`below`,e.classList.add(`sym-card-on`)},[n]),n?(0,S.jsx)(`div`,{ref:i,className:`sym-card`,role:`dialog`,"aria-label":`usages of ${n.word}`,children:(0,S.jsx)(Vu,{word:n.word,side:n.side,groups:c,here:n.line===null?null:{hunkId:n.hunkId,line:n.line},onJump:e=>{a.current(),t(e)}},`${n.side}:${n.word}`)}):null}function Vu({word:e,side:t,groups:n,here:r,onJump:i}){let[a,o]=(0,x.useState)(()=>new Set),s=e=>o(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),c=Ru(n),l=r?Math.max(0,c-1):c;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`sym-card-head`,children:[(0,S.jsx)(`code`,{className:`sym-card-word`,children:e}),(0,S.jsxs)(`span`,{className:`sym-card-count`,children:[l===0?`nowhere else in this change`:`${l} other ${l===1?`usage`:`usages`}`,t===`base`&&(0,S.jsx)(`span`,{className:`sym-card-side`,children:`before`})]})]}),c>0&&(0,S.jsx)(`div`,{className:`sym-card-list`,children:n.map(e=>{let n=a.has(e.path),o=r?e.usages.filter(e=>Hu(e,r)).length:0;return(0,S.jsxs)(`div`,{className:`sym-card-file`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`sym-card-path`,"aria-expanded":n,title:e.path,onClick:()=>s(e.path),children:[(0,S.jsx)(U,{name:`chev`,size:`sm`}),(0,S.jsx)(Uu,{path:e.path}),(0,S.jsxs)(`span`,{className:`sym-card-n`,children:[e.usages.length-o,o>0&&(0,S.jsx)(`span`,{className:`sym-card-n-here`,children:` + here`})]})]}),n&&e.usages.map(e=>{let n=r!==null&&Hu(e,r);return(0,S.jsxs)(`button`,{type:`button`,className:`sym-card-row${n?` sym-card-here`:``}`,"aria-current":n?`location`:void 0,onClick:()=>i({path:e.path,side:t,line:e.line}),children:[(0,S.jsx)(`span`,{className:`sym-card-ln`,children:e.line}),(0,S.jsx)(Gu,{usage:e})]},`${e.hunkId}:${e.line}`)})]},e.path)})})]})}function Hu(e,t){return e.hunkId===t.hunkId&&e.line===t.line}function Uu({path:e}){let t=e.lastIndexOf(`/`);return t===-1?(0,S.jsx)(`span`,{className:`sym-card-name`,children:e}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`sym-card-name`,children:e.slice(t+1)}),(0,S.jsx)(`span`,{className:`sym-card-dir`,children:e.slice(0,t)})]})}var Wu=28;function Gu({usage:e}){let t=e.text,n=t.search(/\S|$/),r=!1;e.col-n>Wu&&(n=t.lastIndexOf(` `,e.col-Wu+8)+1,(n<=0||e.col-n>56)&&(n=e.col-Wu),r=!0);let i=t.slice(n,e.col),a=t.slice(e.col,e.col+Ku(t,e.col)),o=t.slice(e.col+a.length);return(0,S.jsxs)(`span`,{className:`sym-card-code`,children:[r&&(0,S.jsx)(`span`,{className:`sym-card-ellipsis`,children:`…`}),i,(0,S.jsx)(`mark`,{children:a}),o]})}function Ku(e,t){let n=Mu(e,t);return n&&n.start===t?n.end-t:0}function qu(e,t){let n=document;if(n.caretPositionFromPoint){let r=n.caretPositionFromPoint(e,t);return r?{node:r.offsetNode,offset:r.offset}:null}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);return r?{node:r.startContainer,offset:r.startOffset}:null}return null}function Ju(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let e=n.nextNode();e;e=n.nextNode())t.push(e);return t}function Yu(e,t,n){let r=document.createRange(),i=0,a=!1;for(let o of Ju(e)){let e=o.data.length;if(!a&&t<i+e&&(r.setStart(o,t-i),a=!0),a&&n<=i+e)return r.setEnd(o,n-i),r;i+=e}return null}function Xu(e,t,n,r){let i=e.closest?.(`td[data-side]`);if(!(i instanceof HTMLElement)||e.closest(`.nosym`))return null;let a=qu(t,n);if(!a||a.node.nodeType!==Node.TEXT_NODE||!i.contains(a.node))return null;let o=a.offset;for(let e of Ju(i)){if(e===a.node)break;o+=e.data.length}let s=Mu(i.textContent??``,o);if(!s||!Pu(s.word))return null;let c=Yu(i,s.start,s.end)?.getBoundingClientRect();if(!c||t<c.left-1||t>c.right+1||n<c.top-1||n>c.bottom+1)return null;let l=i.closest(`[data-hunk-id]`)?.getAttribute(`data-hunk-id`);if(!l)return null;let u=r.get(l);if(!u)return null;let d=i.dataset.side===`base`?`base`:`head`,f=Number(d===`base`?i.dataset.old:i.dataset.new);return{word:s.word,side:d,path:u,hunkId:l,line:Number.isFinite(f)&&f>0?f:null,cell:i,start:s.start,end:s.end}}function Z(e,t){let n=globalThis.CSS?.highlights;if(!n||typeof Highlight>`u`)return;let r=RegExp(`(?<![\\w$])${e.replace(/[$\\]/g,`\\$&`)}(?![\\w$])`,`g`),i=new Highlight,a=window.innerHeight,o=t===`base`?`td[data-old]`:`td[data-new]`;for(let e of document.querySelectorAll(`.hunk-lines`)){let t=e.getBoundingClientRect();if(!(t.bottom<0||t.top>a))for(let t of e.querySelectorAll(o)){let e=t.textContent;if(e)for(let n of e.matchAll(r)){let e=Yu(t,n.index,n.index+n[0].length);e&&i.add(e)}}}n.set(zu,i)}function Q(){globalThis.CSS?.highlights?.delete(zu)}var Zu=12e3;function Qu({status:e,onShown:t,onAcknowledge:n}){let r=(0,x.useRef)(e.notice===`pending`),i=(0,x.useRef)(!1),a=e.enabled&&e.notice!==`acknowledged`;(0,x.useEffect)(()=>{a&&r.current&&!i.current&&(i.current=!0,t())},[a,t]);let[o,s]=(0,x.useState)(!1),c=(0,x.useRef)(Zu),[l,u]=(0,x.useState)(Zu);return(0,x.useEffect)(()=>{if(!a||o)return;let e,t,r=0,i=()=>Math.max(0,c.current-(Date.now()-r)),s=()=>{e===void 0&&(r=Date.now(),e=setTimeout(n,c.current),t=setInterval(()=>u(i()),250))},l=()=>{e!==void 0&&(clearTimeout(e),clearInterval(t),e=void 0,c.current=i(),u(c.current))},d=()=>document.visibilityState===`visible`?s():l();return d(),document.addEventListener(`visibilitychange`,d),()=>{l(),document.removeEventListener(`visibilitychange`,d)}},[a,o,n]),a?(0,S.jsxs)(`div`,{className:`telemetry-notice`,role:`status`,"aria-live":`polite`,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),onFocus:()=>s(!0),onBlur:()=>s(!1),children:[(0,S.jsx)(U,{name:`note`,size:`sm`}),(0,S.jsxs)(`p`,{className:`telemetry-notice-text`,children:[(0,S.jsx)(`strong`,{children:`Diffo sends anonymous usage data.`}),` Two small events per review, opened and finished: the version, your OS, the kind of review, which agent, and counts. Never code, paths, or comment text.`,` `,r.current?`Nothing has been sent yet, and nothing is during this review. `:``,`Turn it off any time under Settings → Privacy.`,` `,(0,S.jsx)(`a`,{href:e.docs,target:`_blank`,rel:`noreferrer`,children:`What is sent`})]}),(0,S.jsxs)(`span`,{className:`telemetry-notice-ok`,children:[(0,S.jsxs)(`svg`,{className:`telemetry-notice-ring`,viewBox:`0 0 40 40`,"aria-hidden":`true`,children:[(0,S.jsx)(`circle`,{className:`telemetry-notice-ring-track`,cx:`20`,cy:`20`,r:$u}),(0,S.jsx)(`circle`,{className:`telemetry-notice-ring-left`,cx:`20`,cy:`20`,r:$u,strokeDasharray:ed,strokeDashoffset:ed*(1-l/Zu)})]}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-sm telemetry-notice-ok-btn`,title:`dismiss; it closes on its own in a few seconds`,onClick:n,children:`OK`})]})]}):null}var $u=18,ed=2*Math.PI*$u;function td(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function nd({item:e,current:t,onOpen:n,onResolve:r,onReopen:i,onDelete:a}){let o=e.turn===`resolved`,s=at(e.thread),c=o?i:r,l=e.turn===`yours`||e.turn===`unanswered`,u=e.anchor??`the whole changeset`,d=e.outdated?`, outdated on GitHub: the line left the diff`:e.gone?`, this file left the changeset`:``;return(0,S.jsxs)(`div`,{className:`crow${l?` crow-hot`:``}${o?` crow-done`:``}`,"aria-current":t?`true`:void 0,"data-thread":e.thread.id,children:[s?(0,S.jsx)(`button`,{type:`button`,className:`crow-mark`,"data-tip":`Discard draft: drops it; nothing was posted`,"aria-label":`Discard draft`,disabled:!a,onClick:()=>a&&void a(e.thread.id),children:(0,S.jsx)(U,{name:`trash`,size:`sm`})}):(0,S.jsx)(`button`,{type:`button`,className:`crow-mark`,"aria-pressed":o,"data-tip":o?`Reopen: moves back to its turn`:`Resolve: moves to Settled`,"aria-label":o?`Reopen thread`:`Resolve thread`,disabled:!c,onClick:()=>c&&void c(e.thread.id),children:(0,S.jsx)(U,{name:`check`,size:`sm`})}),(0,S.jsxs)(`button`,{type:`button`,className:`crow-pick`,title:`${u}${d}`,onClick:()=>n?.(e),children:[(0,S.jsx)(`span`,{className:`crow-q`,children:e.question}),(0,S.jsxs)(`span`,{className:`crow-sub`,children:[e.turn===`note`&&it(e.thread)&&(0,S.jsx)(`span`,{className:`crow-pill`,children:`Draft`}),rt(e.thread)!==null&&(0,S.jsxs)(`span`,{className:`crow-pill crow-pill-pr`,title:`your agent drafted a review comment for the author`,children:[(0,S.jsx)(U,{name:`globe`,size:`sm`}),` suggests`]}),e.thread.intent&&e.turn!==`proposed`&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`crow-kind crow-kind-${e.thread.intent}`,children:xc[e.thread.intent]}),(0,S.jsx)(`span`,{className:`crow-sep`,children:`·`})]}),(0,S.jsx)(`span`,{className:`crow-where${e.gone?` crow-where-gone`:``}`,children:td(u)}),it(e.thread)?id(e)&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`crow-sep`,children:`·`}),(0,S.jsx)(`span`,{className:`crow-state`,children:id(e)})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`crow-sep`,children:`·`}),(0,S.jsx)(`span`,{className:`crow-state crow-state-${e.turn}`,children:rd(e)})]})]})]}),(0,S.jsx)(`span`,{className:`crow-when`,children:va(e.updatedAt)}),a&&!s&&(0,S.jsx)(`button`,{type:`button`,className:`row-act row-act-danger crow-del`,"data-tip":`Delete thread`,"aria-label":`Delete thread`,onClick:()=>void a(e.thread.id),children:(0,S.jsx)(U,{name:`trash`,size:`sm`})})]})}function rd(e){switch(e.turn){case`yours`:return e.outcome===`changed`?`changed the code, no reply`:e.answer??`answered`;case`unanswered`:return`no answer, the agent moved on`;case`proposed`:return`from the agent: reply or resolve`;case`agent`:return e.working?`agent is on it`:e.queued===void 0?`waiting on the agent`:`queued, ${Tc(e.queued)}`;case`note`:return`draft, not sent`;case`posted`:return e.answer??`on GitHub`;case`resolved`:return e.answer??`resolved`}}function id(e){let t=e.thread;if(e.turn===`note`)return null;if(ot(t).length>0)return`reply pending`;if(t.queued?.resolve)return`resolves when you submit`;if(t.queued?.unresolve)return`reopens when you submit`;let n=ad(t);return e.turn===`resolved`?n?`${n} · resolved`:`resolved`:n??`on GitHub`}function ad(e){for(let t=e.messages.length-1;t>=0;t--){let n=e.messages[t];if(n.author===`github`&&n.github)return n.github.user.login}return null}var od=new Set([`settled`]),sd={github:{icon:`globe`,label:`GitHub`,empty:`No PR comments yet`},agent:{icon:`lock`,label:`Private`,empty:`Nothing asked of the agent yet`}},cd=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function ld(e,t){let n=e=>t.filter(e).length;if(e===`github`){let e=n(e=>e.turn===`note`);return e>0?{text:cd(e,`draft`),hot:!1}:null}let r=n(e=>e.turn===`yours`||e.turn===`unanswered`);if(r>0)return{text:`${r} your turn`,hot:!0};let i=n(e=>e.turn===`proposed`);if(i>0)return{text:`${i} from the agent`,hot:!1};let a=n(e=>e.turn===`agent`);return a>0?{text:`${a} waiting`,hot:!1}:null}function ud({side:e,group:t,selectedThreadId:n,row:r}){let[i,a]=(0,x.useState)(!1),[o,s]=(0,x.useState)(`auto`),[c,l]=(0,x.useState)(`auto`),[u,d]=(0,x.useState)(n),f=fs()?.viewer.login??null,p=sd[e],m=ld(e,t),h=t.filter(e=>e.turn!==`resolved`),g=t.filter(e=>e.turn===`resolved`),_=e===`github`?h.filter(e=>Cs(e.thread,f)):h,v=h.filter(e=>!_.includes(e)),y=e=>e.thread.id===n;u!==n&&(d(n),o===`closed`&&v.some(y)&&s(`auto`),c===`closed`&&g.some(y)&&l(`auto`));let b=(e,t)=>e===`open`||e===`auto`&&t,C=b(o,v.some(y)),w=C?[..._,...v]:_,T=b(c,g.some(y));return(0,S.jsxs)(`section`,{className:`side side-${e}`,"aria-label":`${p.label} threads`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`side-head`,"aria-expanded":!i,onClick:()=>a(!i),children:[(0,S.jsx)(`span`,{className:`chevron${i?` chevron-shut`:``}`,children:(0,S.jsx)(U,{name:`chev`,size:`sm`})}),(0,S.jsx)(U,{name:p.icon,size:`sm`}),(0,S.jsx)(`span`,{className:`side-name`,children:p.label}),` `,(0,S.jsx)(`span`,{className:`side-n`,children:t.length}),m&&(0,S.jsxs)(S.Fragment,{children:[` `,(0,S.jsx)(`span`,{className:`side-badge${m.hot?` side-badge-hot`:``}`,children:m.text})]})]}),!i&&t.length===0&&(0,S.jsx)(`div`,{className:`side-empty`,children:p.empty}),!i&&w.map(r),!i&&(v.length>0||g.length>0)&&(0,S.jsxs)(`div`,{className:`side-tail`,children:[v.length>0&&(0,S.jsx)(`button`,{type:`button`,className:`side-more`,"aria-expanded":C,title:C?`back to the threads you are part of`:`threads on this pull request you are not part of, bots included`,onClick:()=>s(C?`closed`:`open`),children:C?`Only mine`:`${v.length} from others`}),g.length>0&&(0,S.jsxs)(`button`,{type:`button`,className:`side-more`,"aria-expanded":T,onClick:()=>l(T?`closed`:`open`),children:[g.length,` `,e===`github`?`resolved`:`settled`]})]}),!i&&T&&g.map(r)]})}function dd({items:e,pastItems:t=[],selectedThreadId:n,totalThreads:r,onOpen:i,onResolve:a,onReopen:o,onDelete:s,onClearAll:c,pr:l=!1}){let[u,d]=(0,x.useState)(od),f=(0,x.useMemo)(()=>[...e,...t.map(e=>({...e,gone:!0}))],[e,t]),p=(0,x.useMemo)(()=>Os(f),[f]),m=(0,x.useMemo)(()=>l?ws(f):null,[l,f]),h=(e,t)=>e===`yours`&&a?{icon:`check`,danger:!1,label:`Resolve all ${t.length}`,run:()=>t.forEach(e=>void a(e.thread.id))}:e===`settled`&&s?{icon:`trash`,danger:!0,label:`Delete all ${t.length} settled`,run:()=>t.forEach(e=>void s(e.thread.id))}:null,g=c&&(0,S.jsxs)(`button`,{type:`button`,className:`clist-clear`,onClick:c,children:[`Clear all threads`,r!==void 0&&r>0?` (${r})`:``,`…`]}),_=e=>(0,S.jsx)(nd,{item:e,current:n===e.thread.id,onOpen:i,onResolve:a,onReopen:o,onDelete:s},e.thread.id);if(m)return(0,S.jsxs)(`div`,{className:`clist clist-pr`,children:[[`github`,`agent`].map(e=>(0,S.jsx)(ud,{side:e,group:m[e],selectedThreadId:n,row:_},e)),f.length>0&&g]});if(p.size===0)return(0,S.jsx)(`div`,{className:`clist`,children:(0,S.jsxs)(`div`,{className:`rail-empty`,children:[`No threads yet.`,(0,S.jsx)(`br`,{}),`Comment on any diff line to start one.`]})});let v=p.size===1&&p.has(`settled`);return(0,S.jsxs)(`div`,{className:`clist`,children:[v&&(0,S.jsxs)(`div`,{className:`clist-quiet`,children:[`Nothing needs you.`,(0,S.jsx)(`br`,{}),(0,S.jsxs)(`span`,{className:`clist-quiet-n`,children:[p.get(`settled`).length,` settled.`]})]}),[...p].map(([e,t])=>{let n=u.has(e),r=h(e,t);return(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`div`,{className:`sec-row${r?` sec-row-hasact`:``}`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`sec-head sec-head-fold${e===`yours`?` sec-head-hot`:``}`,"aria-expanded":!n,onClick:()=>d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),children:[(0,S.jsx)(`span`,{className:`chevron${n?` chevron-shut`:``}`,children:(0,S.jsx)(U,{name:`chev`,size:`sm`})}),vs[e],` `,(0,S.jsx)(`span`,{className:`sec-n`,children:t.length})]}),r&&(0,S.jsx)(`button`,{type:`button`,className:`row-act sec-act${r.danger?` row-act-danger`:``}`,"data-tip":r.label,"aria-label":r.label,onClick:r.run,children:(0,S.jsx)(U,{name:r.icon,size:`sm`})})]}),!n&&t.map(_)]},e)}),g]})}var fd=`diffo:ui:critter`;function pd(){try{return localStorage.getItem(fd)!==`off`}catch{return!0}}function md(e){try{e?localStorage.removeItem(fd):localStorage.setItem(fd,`off`)}catch{}}async function hd(){try{let e=await fetch(`/api/settings`);if(!e.ok)return null;let t=await e.json();return t?.critter===`on`||t?.critter!==`off`&&null}catch{return null}}function gd(){let[e,t]=(0,x.useState)(pd);return(0,x.useEffect)(()=>{let e=!1;return hd().then(n=>{e||n===null||n===pd()||(md(n),t(n))}),()=>{e=!0}},[]),[e,(0,x.useCallback)(e=>{t(e),md(e),fetch(`/api/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({critter:e?`on`:`off`})}).catch(()=>{})},[])]}function _d(e,t){return e===`j`?`next-hunk`:e===`]`?`next-layer`:e===`[`?`prev-layer`:e===`.`?`next-decision`:e===`k`?`prev-hunk`:e===`J`||t&&e===`j`?`next-file`:e===`K`||t&&e===`k`?`prev-file`:e===`v`?`toggle-viewed`:e===`u`?`toggle-view-mode`:e===`b`?`toggle-nav`:e===`/`?`focus-search`:e===`c`?`comment`:e===`n`?`next-unreviewed`:e===`o`?`toggle-fold`:e===`h`?`hide-reviewed`:e===`?`?`shortcuts`:null}function vd(e){return e instanceof HTMLElement?e.tagName===`INPUT`||e.tagName===`TEXTAREA`||e.isContentEditable:!1}var yd={changedHunkIds:new Set,changedFiles:[],changed:new Set},bd=new Set,xd=e=>e.hunks.length>0;function Sd(e,t,n=bd){if(!e||!t)return yd;let r=new Set(t.hunkIds),i=new Set,a=[];for(let t of e.files){if(!xd(t))continue;let e=t.hunks.filter(e=>!r.has(e.id)&&!n.has(e.id));if(e.length!==0){for(let t of e)i.add(t.id);a.push(t.path)}}return{changedHunkIds:i,changedFiles:a,changed:new Set(a)}}function Cd(){let e=w(),t=H({queryKey:[`telemetry`],queryFn:async()=>{try{let e=await fetch(`/api/telemetry`);return e.ok?await e.json():null}catch{return null}},staleTime:1/0}),n=async t=>{try{let n=await fetch(`/api/telemetry`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});n.ok&&e.setQueryData([`telemetry`],await n.json())}catch{}};return{status:t.data??null,markShown:()=>void n({notice:`shown`}),acknowledge:()=>void n({notice:`acknowledged`}),setEnabled:e=>void n({enabled:e})}}var wd=`diffo:ui:theme`;function Td(e){return e===`system`||e===`light`||e===`dark`?e:null}function Ed(){let e=localStorage.getItem(wd);return e===`light`||e===`dark`?e:`system`}function Dd(e){e===`system`?localStorage.removeItem(wd):localStorage.setItem(wd,e)}function Od(e){e===`system`?document.documentElement.removeAttribute(`data-theme`):document.documentElement.setAttribute(`data-theme`,e)}async function kd(){try{let e=await fetch(`/api/settings`);return e.ok?Td((await e.json())?.theme):null}catch{return null}}function Ad(e){fetch(`/api/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({theme:e})}).catch(()=>{})}function jd(){let[e,t]=(0,x.useState)(Ed);return(0,x.useEffect)(()=>{let e=!1;return kd().then(n=>{e||n===null||n===Ed()||(Dd(n),Od(n),t(n))}),()=>{e=!0}},[]),[e,(0,x.useCallback)(e=>{t(e),Od(e),Dd(e),Ad(e)},[])]}var Md=(e,t)=>`${e}:${t}`;function Nd(e){return e.flatMap(e=>e.messages.filter(e=>e.author===`agent`).map(t=>Md(e.id,t.id)))}function Pd(e){let t=e.anchor;return t.kind===`changeset`?null:t.kind===`file`?t.path:t.kind===`layer`?`layer “${t.title}”`:`${t.path}:${t.line}`}function Fd(e,t){let n=[];for(let r of e){let e=[...r.messages].reverse().find(e=>e.author===`agent`);if(!e||t.has(Md(r.id,e.id)))continue;let i=lt(r);n.push({key:Md(r.id,e.id),kind:i?r.anchor.kind===`changeset`?`guide`:`thread`:`answer`,threadId:r.id,anchor:Pd(r),preview:e.text.split(`
93
- `,1)[0].trim()})}return n}function Id(e,t){return e>0?`(${e}) ${t}`:t}function Ld(e,t,n=!1){return e?n?`dev · ${e}`:e:t}var Rd=8e3;function zd(e,t){let n=0;return e.map(e=>e.kind===`guide`?e:{...e,expiresAt:t+350*n++})}function Bd(e,t){let n=-1/0;for(let t of e)t.expiresAt!==null&&t.expiresAt>n&&(n=t.expiresAt);return Math.max(t+Rd,n+350)}function Vd(e){let t=document;if(typeof t.startViewTransition!=`function`){e();return}let n=t.startViewTransition(()=>(0,kt.flushSync)(e));n.ready.catch(()=>{}),n.finished.catch(()=>{})}function Hd({threads:e,title:t,onOpenThread:n}){let[r,i]=(0,x.useState)([]),a=(0,x.useRef)(null),o=(0,x.useRef)(document.title),s=(0,x.useRef)(Rt()),c=(0,x.useRef)(t),l=(0,x.useRef)(0),u=(0,x.useRef)(n);u.current=n;let d=(0,x.useCallback)(()=>{document.title=Id(l.current,Ld(c.current,o.current,s.current))},[]);(0,x.useEffect)(()=>{c.current=t,d()},[t,d]),(0,x.useEffect)(()=>{if(!e)return;if(a.current===null){a.current=new Set(Nd(e));return}let t=Fd(e,a.current);for(let t of Nd(e))a.current.add(t);if(t.length===0)return;if(document.hasFocus()){let e=Date.now(),n=t.map(e=>({...e,expiresAt:null}));Vd(()=>i(t=>[...t,...zd(n,Bd(t,e))]));return}l.current+=t.length,d();let n=t.map(e=>({...e,expiresAt:null}));Vd(()=>i(e=>[...e.map(e=>e.expiresAt===null?e:{...e,expiresAt:null}),...n]))},[e,d]),(0,x.useEffect)(()=>{let e=()=>{l.current=0,d();let e=Date.now()+Rd;i(t=>zd(t,e))};return window.addEventListener(`focus`,e),()=>{window.removeEventListener(`focus`,e),l.current=0,d()}},[d]),(0,x.useEffect)(()=>{let e=1/0;for(let t of r)t.expiresAt!==null&&t.expiresAt<e&&(e=t.expiresAt);if(e===1/0)return;let t=setTimeout(()=>{let e=Date.now();Vd(()=>i(t=>t.filter(t=>t.expiresAt===null||t.expiresAt>e)))},Math.max(0,e-Date.now()));return()=>clearTimeout(t)},[r]);let f=(0,x.useCallback)(()=>Vd(()=>i([])),[]),p=(0,x.useCallback)(e=>{Vd(()=>i(t=>t.filter(t=>t.key!==e.key)))},[]);return{notices:r,open:(0,x.useCallback)(e=>{Vd(()=>i(t=>t.filter(t=>t.key!==e.key))),u.current(e.threadId)},[]),dismiss:p,clear:f}}function Ud(e){return`diffo:viewed:${e.repo.path}:${Gd(e)}`}function Wd(e){return`diffo:viewed:${e.repo.name}:${Gd(e)}`}function Gd(e){return e.spec.kind===`working-tree`?`working-tree`:`branch:${e.spec.base}`}function Kd(e){try{let t=localStorage.getItem(e);if(!t)return new Set;let n=JSON.parse(t);return Array.isArray(n)?new Set(n.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}function qd(e,t){try{localStorage.setItem(e,JSON.stringify([...t]))}catch{}}function Jd(e){let t=e?Ud(e):null,n=e?Wd(e):null,[r,i]=(0,x.useState)(new Set),[a,o]=(0,x.useState)(!1);(0,x.useEffect)(()=>{if(!t)return;let e=Kd(t);if(e.size===0&&n!==null&&n!==t){let e=Kd(n);if(e.size>0){qd(t,e),i(e),o(!0);return}}i(e),o(!0)},[t,n]);let s=(0,x.useCallback)(n=>{let r=e?.files.find(e=>e.path===n);r&&i(e=>{let n=new Set(e),i=uo(r),a=i.every(e=>n.has(e));for(let e of i)a?n.delete(e):n.add(e);return t&&qd(t,n),n})},[e,t]),c=(0,x.useCallback)((n,r)=>{let a=new Set(n);i(n=>{let i=new Set(n);for(let t of e?.files??[])if(a.has(t.path))for(let e of uo(t))r?i.add(e):i.delete(e);return t&&qd(t,i),i})},[e,t]);return{viewed:r,loaded:a,toggleFile:s,markFiles:(0,x.useCallback)(e=>c(e,!0),[c]),clearFiles:(0,x.useCallback)(e=>c(e,!1),[c]),progress:(0,x.useMemo)(()=>{let t=0,n=0;for(let i of e?.files??[])for(let e of i.hunks)t++,r.has(e.id)&&n++;return{viewed:n,total:t}},[e,r]),fileProgress:(0,x.useMemo)(()=>{let t=0,n=0;for(let i of e?.files??[])t++,po(i,r)&&n++;return{viewed:n,total:t}},[e,r])}}var Yd=new Ue,Xd=264,Zd=800,Qd=200,$d=520,ef=e=>Math.min($d,Math.max(Qd,e)),tf=12,nf=`overview`,rf=16,af=new Set,of=new Map;function sf(e){e.removeAttribute(`data-found`),e.offsetWidth,e.setAttribute(`data-found`,``);let t=()=>e.removeAttribute(`data-found`);e.addEventListener(`animationend`,t,{once:!0}),setTimeout(t,2e3)}var cf=[];function lf(){let e=w(),[t,n]=(0,x.useState)(`waiting`),[r,i]=(0,x.useState)(null),[a,o]=(0,x.useState)(`no-agent`),[s,c]=(0,x.useState)(null),[l,u]=(0,x.useState)(af),[d,f]=(0,x.useState)(of),[p,m]=(0,x.useState)(af);return(0,x.useEffect)(()=>{let t=new EventSource(`/api/events`);return t.addEventListener(`changeset`,()=>{e.invalidateQueries({queryKey:[`changeset`]})}),t.addEventListener(`review`,()=>{e.invalidateQueries({queryKey:[`review`]})}),t.addEventListener(`presence`,e=>{try{let t=JSON.parse(e.data),{state:r}=t;(r===`waiting`||r===`listening`||r===`working`)&&(n(r),i(t.layers===`queued`||t.layers===`outlining`?t.layers:null),t.reason&&o(t.reason),c(typeof t.since==`number`?t.since:null),u(r===`working`&&Array.isArray(t.workingOn)?new Set(t.workingOn.filter(e=>typeof e==`string`)):af),f(r!==`waiting`&&Array.isArray(t.queued)?new Map(t.queued.filter(e=>typeof e==`string`).map((e,t)=>[e,t+1])):of),m(r!==`waiting`&&Array.isArray(t.answered)?new Set(t.answered.filter(e=>typeof e==`string`)):af))}catch{}}),t.onopen=()=>{e.invalidateQueries({queryKey:[`review`]}),e.invalidateQueries({queryKey:[`changeset`]})},t.onerror=()=>{n(`waiting`),o(`disconnected`),c(null),u(af),f(of),m(af),i(null)},()=>t.close()},[e]),{presence:t,reason:a,since:s,workingOn:l,queuedOn:d,answeredOn:p,layersRequest:r}}function uf(e,t,n){let[r,i]=(0,x.useState)(null),a=(0,x.useRef)(af);return(0,x.useEffect)(()=>{let r=a.current;if(a.current=t,n!==`working`||t.size===0){i(null);return}let o=[...t].filter(e=>!r.has(e));if(o.length===0)return;let s=e.find(e=>e.thread.id===o[o.length-1]);s&&i(Es(s.anchor))},[e,t,n]),r}function df(){let e=w();return(0,x.useMemo)(()=>{let t=()=>e.invalidateQueries({queryKey:[`review`]});return{create:async(e,n,r,i)=>{let a=await St.createThread(e,n,r,i);return await t(),a},reply:(e,n,r)=>St.reply(e,n,r).then(t),edit:(e,n,r,i)=>St.editMessage(e,n,r,i).then(t),send:async e=>{let{prompt:n,delivered:r,presence:i}=await St.send(e);if(r||i!==`waiting`)return await t(),{delivered:!0};let a=await Ct(n);return await t(),{delivered:!1,copied:a,prompt:n}},resolve:e=>St.setState(e,`resolved`).then(t),reopen:e=>St.setState(e,`open`).then(t),remove:e=>St.remove(e).then(t),dismissPrComment:(e,n)=>St.dismissPrComment(e,n).then(t)}},[e])}function ff(){let{data:e,isLoading:t,error:n}=mt(),{presence:r,reason:i,since:a,workingOn:o,queuedOn:s,answeredOn:c,layersRequest:l}=lf(),{viewed:u,loaded:d,toggleFile:f,markFiles:p,clearFiles:m,progress:h,fileProgress:g}=Jd(e),[_,v]=(0,x.useState)(`unified`),[y,b]=(0,x.useState)(null),[C,w]=(0,x.useState)(null),[T,E]=(0,x.useState)(new Set),[D,O]=(0,x.useState)(()=>{let e=localStorage.getItem(`diffo:ui:navHidden`);return e===null?window.innerWidth<Zd:e===`1`}),[k,A]=(0,x.useState)(()=>{let e=Number(localStorage.getItem(`diffo:ui:railWidth`));return e>0?ef(e):Xd}),[j,M]=(0,x.useState)(!1),N=(0,x.useRef)(null),P=(0,x.useRef)(k);P.current=j?P.current:k;let F=(0,x.useRef)(null);(0,x.useEffect)(()=>()=>F.current?.(),[]);let{data:I}=ht(),ee=df(),[te,ne]=(0,x.useState)(null),[L,re]=(0,x.useState)(null),[ie,ae]=(0,x.useState)(!1),[oe,se]=(0,x.useState)(!1),[ce,le]=(0,x.useState)(!1),[ue,de]=(0,x.useState)(!1),[R,z]=(0,x.useState)(!1),[B,fe]=jd(),[pe,me]=gd(),he=Cd(),[ge,_e]=(0,x.useState)(!1),[ve,ye]=(0,x.useState)(`files`),[be,xe]=(0,x.useState)(0),Se=e?.pr??null,Ce=r!==`waiting`,[we,Te]=(0,x.useState)(!1),Ee=(0,x.useMemo)(()=>Sd(e,I?.lastFinish,u),[e,I,u]),De=(0,x.useMemo)(()=>$o(e?.files??[]),[e]),V=Jo(De,(0,x.useCallback)(e=>po(e,u),[u]),{on:we,changed:Ee.changed,set:Te}),Oe=(0,x.useMemo)(()=>vo(I?.layers,De),[I?.layers,De]),ke=Oe.length>0,Ae=(0,x.useMemo)(()=>Co(Oe),[Oe]),je=(0,x.useMemo)(()=>V.hideTests?yo(Oe,e=>Ho(e.path)&&!V.pinned.has(e.path)):Oe,[Oe,V.hideTests,V.pinned]),[Me,Ne]=(0,x.useState)(null),[Pe,Fe]=(0,x.useState)(null);(0,x.useEffect)(()=>Fe(null),[Me]);let Ie=(0,x.useMemo)(()=>xo(I?.threads??[]),[I?.threads]),Le=(0,x.useMemo)(()=>Se?So(I?.threads??[]):void 0,[Se,I?.threads]),Re=Ie!==void 0||Le!==void 0,ze=ke&&Me===nf&&Re,Be=Oe.findIndex(e=>bo(e)===Me),Ve=(0,x.useMemo)(()=>Oe.every(e=>e.files.every(e=>!po(e.file,u))),[Oe,u]),He=ke?ze?-1:Be===-1?Oo(je,u):Be:-1,Ue=ke&&He>=0?je[He]:void 0,We=ke&&He>=0?Oe[He]:void 0,Ge=ke&&ve===`layers`,Ke=Ge?Ue:void 0;(0,x.useEffect)(()=>{ke&&d&&Be===-1&&!ze&&Ne(Re&&Ve&&Me===null?nf:bo(Oe[He]))},[ke,d,Be,ze,Oe,He,Re,Ve,Me]);let qe=(0,x.useMemo)(()=>Ge&&ze?[]:Ke?Ke.files.map(e=>e.file):V.files,[Ge,ze,Ke,V.files]),Je=(0,x.useCallback)(e=>e.files.length===0,[]),[Ye,Xe]=(0,x.useState)(tf),Ze=(0,x.useCallback)(()=>Xe(e=>e+tf),[]),Qe=(0,x.useCallback)(e=>{let t=Oe[e];t&&(Ne(bo(t)),b(null),w(null),Xe(tf),requestAnimationFrame(()=>{document.querySelector(`.reading-pane`)?.scrollTo({top:0})}))},[Oe]),$e=(0,x.useCallback)(()=>{Ne(nf),b(null),w(null),requestAnimationFrame(()=>{document.querySelector(`.reading-pane`)?.scrollTo({top:0})})},[]),et=(0,x.useCallback)(e=>{if(!Ge||We?.files.some(t=>t.file.path===e))return;let t=Ae.get(e);t&&Qe(Oe.indexOf(t))},[Ge,We,Ae,Oe,Qe]),tt=Ke?.kind===`mechanical`?bo(Ke):null,H=(0,x.useRef)(Ke);H.current=Ke;let nt=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(tt===null)return;let e=nt.current,t=(H.current?.files??[]).map(e=>e.file.path).filter(t=>t!==e);E(e=>new Set([...e,...t]))},[tt]),(0,x.useEffect)(()=>{ke&&ye(`layers`)},[ke]);let rt=(0,x.useCallback)(()=>{St.requestLayers().catch(()=>{})},[]),it=(0,x.useCallback)(e=>{V.pin(e);let t=Ge?We?.files.some(t=>t.file.path===e)?We:Ae.get(e):void 0,n=t?t.files.findIndex(t=>t.file.path===e):De.findIndex(t=>t.path===e);n>=0&&Xe(e=>Math.max(e,n+1))},[De,V.pin,Ge,We,Ae]),ot=(0,x.useMemo)(()=>qe.slice(0,Ye),[qe,Ye]),{active:st,past:ct}=(0,x.useMemo)(()=>{let t=ft(e?.files??[],I?.threads??[],I?.layers),n=t.active.filter(e=>e.github?.outdated===!0);return n.length===0?t:{active:t.active.filter(e=>e.github?.outdated!==!0),past:[...t.past,...n]}},[e,I]),ut=(0,x.useMemo)(()=>Pl(e?.files??[],st),[e,st]),dt=(0,x.useMemo)(()=>Ts(st,o,s),[st,o,s]),pt=(0,x.useMemo)(()=>({stillTo:dt.filter(e=>e.turn===`agent`).sort((e,t)=>(e.working===!0?0:e.queued??2**53-1)-(t.working===!0?0:t.queued??2**53-1)),back:dt.filter(e=>c.has(e.thread.id))}),[dt,c]),gt=(0,x.useMemo)(()=>({segments:[...pt.back.map(()=>`done`),...pt.stillTo.map(e=>e.working===!0?`now`:`wait`)],done:pt.back.length}),[pt]),_t=uf(dt,c,r),vt=r===`working`?Ds(pt.stillTo,_t)??(l===`outlining`?`outlining layers`:null):null,[yt,bt]=(0,x.useState)(!1);(0,x.useEffect)(()=>{yt&&pt.stillTo.length===0&&pt.back.length===0&&bt(!1)},[yt,pt]),(0,x.useEffect)(()=>{we&&Ee.changed.size===0&&Te(!1)},[we,Ee]);let xt=(0,x.useMemo)(()=>Ts(ct),[ct]),Ct=(0,x.useMemo)(()=>js(dt),[dt]),wt=(0,x.useMemo)(()=>Il(e?.files??[],ut),[e,ut]),Et=ks(dt)+ks(xt),Dt=As(dt)+As(xt),kt=dt.length+xt.length-Dt,[At,Mt]=(0,x.useState)(0),[Nt,Ft]=(0,x.useState)(0),[It,Lt]=(0,x.useState)(null),[Rt,zt]=(0,x.useState)(null),Bt=(0,x.useMemo)(()=>({partition:ut,past:ct,actions:ee,agentConnected:Ce,workingOn:o,queuedOn:s,composeHunkId:te,onComposeHandled:()=>ne(null),composeFilePath:L,onComposeFileHandled:()=>re(null),changesetComposerOpen:ie,onOpenChangesetComposer:()=>ae(!0),onCloseChangesetComposer:()=>ae(!1),revealNotesTick:At,revealPastTick:Nt,revealThreadId:It}),[ut,ct,ee,Ce,o,s,te,L,ie,At,Nt,It]),W=(0,x.useMemo)(()=>{let e=0;for(let t of st)ms(t)&&e++;return e},[st]),Vt=(0,x.useMemo)(()=>st.filter(at).length+ct.filter(at).length,[st,ct]),[Ht,Ut]=(0,x.useState)(new Set),Wt=(0,x.useMemo)(()=>{let e=new Set;for(let t of st)lt(t)||(t.anchor.kind===`hunk`||t.anchor.kind===`file`)&&e.add(t.anchor.path);return e},[st]),Gt=(0,x.useMemo)(()=>{let e=De.filter(e=>!po(e,u)),t=e.filter(e=>Ht.has(e.path)).map(e=>e.path),n=new Set(t),r=new Set(V.scope.excludedPaths),i=e.filter(e=>!n.has(e.path));return{viewedHunks:h.viewed,totalHunks:h.total,viewedFiles:g.viewed,totalFiles:g.total,changedFiles:t,commentedUnread:i.filter(e=>Wt.has(e.path)).map(e=>e.path),filteredOut:i.filter(e=>!Wt.has(e.path)&&r.has(e.path)).map(e=>e.path),skippedFiles:i.filter(e=>!Wt.has(e.path)&&!r.has(e.path)).map(e=>e.path)}},[De,h,g,u,Ht,Wt,V.scope.excludedPaths]),Kt=(0,x.useCallback)(async()=>{await St.clear(),await Yd.invalidateQueries({queryKey:[`review`]})},[]),qt=(0,x.useCallback)(()=>{Yd.setQueryData([`review`],e=>e&&{...e,landed:void 0}),St.dismissLanded().then(()=>Yd.invalidateQueries({queryKey:[`review`]}))},[]),Jt=(0,x.useMemo)(()=>{if(I?.landed)return{sha:I.landed.sha,subject:I.landed.subject,threads:I.threads.length,onClear:Kt,onDismiss:qt}},[I,Kt,qt]),Yt=(0,x.useMemo)(()=>{let e=e=>e.turn===`yours`||e.turn===`unanswered`;return[...dt.filter(e),...xt.filter(e).map(e=>({...e,gone:!0}))]},[dt,xt]),Xt=(0,x.useCallback)(async()=>{await Yd.invalidateQueries({queryKey:[`review`]}),await Yd.invalidateQueries({queryKey:[`finish-preview`]})},[]),Zt=(0,x.useCallback)(e=>St.setState(e,`resolved`).then(Xt),[Xt]),Qt=(0,x.useCallback)(e=>St.setState(e,`open`).then(Xt),[Xt]),$t=(0,x.useCallback)(async(e,t)=>{let n={...Gt,...t&&t.note.trim()!==``?{note:t.note.trim()}:{}},{prompt:r,delivered:i,presence:a,public:o}=await St.finish(n,e,t?.event);await Yd.invalidateQueries({queryKey:[`review`]}),await Yd.invalidateQueries({queryKey:[`changeset`]}),await Yd.invalidateQueries({queryKey:[`finish-preview`]});let s=i||a!==`waiting`;return e&&s&&W>0&&!o?.failed&&bt(!0),{prompt:r,delivered:s,...o?{public:o}:{}}},[Gt,W]),en=(0,x.useCallback)(e=>{let t=ef(e);P.current=t,A(t),localStorage.setItem(`diffo:ui:railWidth`,String(t))},[]),tn=(0,x.useCallback)(e=>{if(e.button!==0)return;e.preventDefault();let t=e.clientX,n=P.current,r=n,i=e=>{r=ef(n+e.clientX-t),P.current=r,N.current?.style.setProperty(`--rail-w`,`${r}px`)},a=()=>{F.current?.(),F.current=null,M(!1),en(r)};F.current=()=>{document.removeEventListener(`pointermove`,i),document.removeEventListener(`pointerup`,a),document.removeEventListener(`pointercancel`,a),document.body.style.userSelect=``,document.body.style.cursor=``},document.addEventListener(`pointermove`,i),document.addEventListener(`pointerup`,a),document.addEventListener(`pointercancel`,a),document.body.style.userSelect=`none`,document.body.style.cursor=`col-resize`,M(!0)},[en]),nn=(0,x.useCallback)(()=>en(Xd),[en]),rn=(0,x.useRef)(localStorage.getItem(`diffo:ui:navHidden`)!==null),an=(0,x.useCallback)(()=>{rn.current=!0,O(e=>!e)},[]);(0,x.useEffect)(()=>{rn.current&&localStorage.setItem(`diffo:ui:navHidden`,D?`1`:`0`)},[D]);let on=(0,x.useRef)(!1);(0,x.useEffect)(()=>{if(on.current||!d||!e)return;on.current=!0;let t=e.files.filter(e=>po(e,u)).map(e=>e.path);t.length>0&&E(e=>new Set([...e,...t]))},[d,e,u]);let sn=(0,x.useCallback)(e=>{E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),cn=(0,x.useRef)(null),ln=(0,x.useCallback)(e=>{let t=document.querySelector(`.reading-pane`),n=document.getElementById(zo(e));if(!t||!n)return;let r=t.getBoundingClientRect().top,i=n.getBoundingClientRect(),a=i.top-r+t.scrollTop;i.bottom<=r?cn.current=t.scrollTop-(i.height+rf):i.top<=r&&(cn.current=a)},[]);(0,x.useLayoutEffect)(()=>{let e=cn.current;if(e===null)return;cn.current=null;let t=document.querySelector(`.reading-pane`);t&&(t.scrollTop=Math.max(0,e))});let un=(0,x.useCallback)(t=>{let n=e?.files.find(e=>e.path===t);if(!n)return;let r=po(n,u);!r&&V.hideReviewed&&(ln(t),V.unpin(t)),f(t),E(e=>{let n=new Set(e);return r?n.delete(t):n.add(t),n})},[e,f,u,V.hideReviewed,V.unpin,ln]),dn=(0,x.useCallback)(e=>{let t=n=>{let r=document.getElementById(zo(e));r?Bo(r,sf):n>0&&requestAnimationFrame(()=>t(n-1))};requestAnimationFrame(()=>t(30))},[]),fn=(0,x.useCallback)(e=>{et(e),it(e),E(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n}),dn(e)},[it,et,dn]),pn=(0,x.useCallback)((t,n)=>{let r=e?.files.find(e=>e.path===t);if(!r)return;et(t),it(t),E(e=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n});let i=n===null?void 0:r.hunks.find(e=>e.lines.some(e=>e.kind!==`del`&&e.newNo===n));i?(b(i.id),w(null),requestAnimationFrame(()=>{let e=t=>{let n=document.querySelector(`[data-hunk-id="${i.id}"]`);n?Bo(n,sf):t>0&&requestAnimationFrame(()=>e(t-1))};e(30)})):dn(t)},[e,et,it,dn]),mn=(0,x.useCallback)(({path:t,side:n,line:r})=>{let i=e?.files.find(e=>e.path===t);if(!i)return;et(t),it(t),E(e=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n});let a=i.hunks.find(e=>e.lines.some(e=>(n===`base`?e.oldNo:e.newNo)===r));if(!a){dn(t);return}b(a.id),w(null);let o=`[data-hunk-id="${a.id}"] td[data-${n===`base`?`old`:`new`}="${r}"]`;requestAnimationFrame(()=>{let e=t=>{let n=document.querySelector(o)?.closest(`tr`);n?Bo(n,sf,`center`):t>0&&requestAnimationFrame(()=>e(t-1))};e(30)})},[e,et,it,dn]),hn=(0,x.useMemo)(()=>({paths:De.map(e=>e.path),onJump:pn}),[De,pn]),gn=(0,x.useMemo)(()=>({...Bt,links:hn}),[Bt,hn]),_n=(0,x.useCallback)(e=>{p(e);for(let t of e)V.unpin(t);E(t=>new Set([...t,...e]))},[p,V.unpin]),vn=(0,x.useCallback)(e=>{m(e),E(t=>{let n=new Set(t);for(let t of e)n.delete(t);return n})},[m]),yn=(0,x.useCallback)(()=>{let e=e=>!po(e,u),t;if(Ge){let n=Math.max(He,0),r=[...je.slice(n),...je.slice(0,n)];for(let n of r){let r=n.files.map(e=>e.file).find(e);if(r){t=r,n!==Ue&&Qe(je.indexOf(n));break}}}else t=De.find(e);t&&(it(t.path),E(e=>{if(!e.has(t.path))return e;let n=new Set(e);return n.delete(t.path),n}),b(t.hunks[0]?.id??null),w(t.hunks.length===0?t.path:null),dn(t.path))},[De,u,it,Ge,He,Ue,je,Qe,dn]),bn=(0,x.useCallback)(e=>{if(zt(e.threadId),e.gone)Ft(e=>e+1);else if(e.layerId!==void 0){ye(`layers`);let t=Oe.findIndex(t=>t.id===e.layerId);t!==-1&&bo(Oe[t])!==Me&&Qe(t)}else e.path?(nt.current=e.path,et(e.path),it(e.path),E(t=>{if(!t.has(e.path))return t;let n=new Set(t);return n.delete(e.path),n})):(Ge&&!ze&&(Re?$e():ye(`files`)),Lt(e.threadId),Mt(e=>e+1));let t=n=>{nt.current=null;let r=document.querySelector(`[data-thread-id="${e.threadId}"]`);if(r){Bo(r,sf);return}n>0&&requestAnimationFrame(()=>t(n-1))};requestAnimationFrame(()=>t(30))},[it,et,Oe,Me,Qe,Ge,ze,Re,$e]),xn=(0,x.useCallback)((e,t=!1)=>({threadId:e.thread.id,path:e.path,...e.thread.anchor.kind===`layer`?{layerId:e.thread.anchor.layerId}:{},...t?{gone:t}:{}}),[]),Sn=(0,x.useCallback)(e=>{let t=dt.find(t=>t.thread.id===e);if(t){bn(xn(t));return}let n=xt.find(t=>t.thread.id===e);n&&bn(xn(n,!0))},[dt,xt,bn,xn]),Cn=Hd({threads:I?.threads,title:I?.title,onOpenThread:Sn}),wn=(0,x.useRef)(null),Tn=(0,x.useMemo)(()=>{if(!e)return al;let t=wn.current;return t&&t.version===e.version?al:ol(t,e,Kd(Ud(e)))},[e]);(0,x.useEffect)(()=>{e&&(wn.current=e)},[e]),(0,x.useEffect)(()=>{e&&Tn.changedViewedHunkIds.size!==0&&Ut(t=>{let n=new Set(t);for(let t of e.files)t.hunks.some(e=>Tn.changedViewedHunkIds.has(e.id))&&n.add(t.path);return n.size===t.size?t:n})},[e,Tn]);let G=(0,x.useMemo)(()=>qe.flatMap(e=>e.hunks.map(t=>({id:t.id,path:e.path}))),[qe]);(0,x.useEffect)(()=>{y&&!G.some(e=>e.id===y)&&b(null)},[G,y]);let En=G.find(e=>e.id===y)?.path??C,Dn=(0,x.useCallback)(e=>{if(G.length===0)return;let t=G.findIndex(e=>e.id===y),n=0;if(t!==-1){if(e===`next-hunk`)n=Math.min(t+1,G.length-1);else if(e===`prev-hunk`)n=Math.max(t-1,0);else if(e===`next-file`){let e=G[t].path,r=G.findIndex((n,r)=>r>t&&n.path!==e);n=r===-1?t:r}else{let e=G[t].path,r=[...G.slice(0,t)].reverse().find(t=>t.path!==e);n=r?G.findIndex(e=>e.path===r.path):t}}let{id:r,path:i}=G[n];b(r),w(null),it(i),requestAnimationFrame(()=>{document.querySelector(`[data-hunk-id="${r}"]`)?.scrollIntoView({behavior:`instant`,block:`center`})})},[G,y,it]);(0,x.useEffect)(()=>{let e=e=>{if(e.metaKey||e.ctrlKey||e.altKey||vd(e.target))return;let t=_d(e.key,e.shiftKey);if(t){if(e.preventDefault(),t===`toggle-viewed`)En&&un(En);else if(t===`comment`)y&&ne(y);else if(t===`toggle-view-mode`)v(e=>e===`unified`?`split`:`unified`);else if(t===`toggle-nav`)an();else if(t===`focus-search`)ye(`files`),O(!1),xe(e=>e+1);else if(t===`next-unreviewed`)yn();else if(t===`shortcuts`)de(e=>!e);else if(t===`toggle-fold`)En&&sn(En);else if(t===`hide-reviewed`)V.setHideReviewed(!V.hideReviewed);else if(t===`next-layer`||t===`prev-layer`){if(!Ge)return;let e=Do(je,He,t===`next-layer`?1:-1,Je);e===null?t===`prev-layer`&&Re&&!ze&&$e():Qe(e)}else if(t===`next-decision`){let e=Ke?.decisions;if(!e||e.length===0)return;let t=Pe===null?0:(Pe+1)%e.length;Fe(t);let n=e[t].places.find(e=>e.hunkId);n?pn(n.at.path,n.at.line??null):document.querySelector(`.reading-pane`)?.scrollTo({top:0})}else Dn(t)}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Dn,y,En,un,G,an,yn,sn,V.hideReviewed,V.setHideReviewed,Ge,je,He,Je,Qe,$e,Ie,ze,Ke,Pe,pn]);let On=Oe.filter(e=>!e.derived).length,kn=(0,x.useMemo)(()=>{let e=Ke;if(!e)return;let t=new Map;for(let{file:n,note:r}of e.files)r?t.set(n.path,r):e.kind===`mechanical`&&n.hunks.length>0&&t.set(n.path,`${n.hunks.length} ${n.hunks.length===1?`site`:`sites`}`);return{id:e.id,...e.decisions?{decisions:e.decisions,openDecision:Pe,onOpenDecision:Fe}:{},kicker:e.derived?`Outside the outline`:`Layer ${e.number} of ${On}`,title:e.title,mechanical:e.kind===`mechanical`,...e.derived?{summary:`Files no layer lists: touched after the outline was posted, or left out of it. The agent absorbs them by re-posting.`}:e.summary?{summary:e.summary}:{},missing:e.missing,listed:e.files.length+(e.hidden??0),hidden:e.hidden??0,onJump:pn,notes:t,knownPaths:De.map(e=>e.path)}},[Ke,On,pn,De,Pe]),An=(0,x.useMemo)(()=>{let e=e=>Do(je,He,e,Je),t=e=>e===null?null:{title:Oe[e].title,onGo:()=>Qe(e)};if(Ge&&ze)return{text:Le?`overview · the description`:`overview · the guide`,title:Le?`the author’s description of this change; ] enters the first layer`:`the agent’s orientation to this change; ] enters the first layer`,progress:null,prev:null,next:t(e(1))};let n=Ke;if(!n)return;let r=wo(n,u),i=n.derived?`since your review`:`layer ${n.number} / ${On}`,a=r.files===0?`nothing here`:r.doneFiles===r.files?`read`:`${r.files-r.doneFiles} left`,o=e(-1);return{text:`${i} · ${r.files} ${r.files===1?`file`:`files`} · ${a}`,title:`${r.doneFiles} of ${r.files} files in this layer marked reviewed`,progress:r.marks===0?0:r.doneMarks/r.marks,stats:To(n),prev:o===null?Re?{title:`Overview`,onGo:$e}:null:t(o),next:t(e(1))}},[Ge,ze,Ke,u,Oe,je,He,Je,On,Qe,$e,Le,Re]),jn=r===`waiting`?`noagent`:l??`quiet`;return t?(0,S.jsxs)(`div`,{className:`center-note`,children:[(0,S.jsx)(Ba,{size:44,className:`center-mark`}),(0,S.jsx)(`div`,{className:`shimmer`}),(0,S.jsx)(`div`,{className:`shimmer shimmer-short`}),`Reading the changeset…`]}):n?(0,S.jsxs)(`div`,{className:`center-note center-note-error`,children:[(0,S.jsx)(Tt,{}),(0,S.jsx)(U,{name:`alert`,size:`lg`}),(0,S.jsx)(`h2`,{children:`Diffo couldn't read this changeset`}),(0,S.jsx)(`p`,{children:n.message}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>location.reload(),children:`Try again`})]}):e?(0,S.jsx)(ds.Provider,{value:Se,children:(0,S.jsxs)(`div`,{className:`layout`,children:[(0,S.jsx)(co,{changeset:e,agent:{presence:r,reason:i,since:a,activity:vt,onInvite:()=>z(!0),batch:gt,suggestion:!ke&&l===null&&I?.layersSuggested?{reason:I.layersSuggested.reason,onOutline:rt}:void 0,monitorOpen:yt,onOpenMonitor:bt,monitorPanel:(0,S.jsx)(Lc,{stillTo:pt.stillTo,back:pt.back,onOpen:e=>{bt(!1),bn(xn(e))},onClose:()=>bt(!1)})},review:{openComments:W,publicDrafts:Vt,onFinishReview:()=>se(!0)},settings:{theme:B,onSetTheme:fe,critter:pe,onSetCritter:me,...he.status?{onShowPrivacy:()=>_e(!0)}:{},onShowShortcuts:()=>de(!0)}}),(0,S.jsxs)(`div`,{ref:N,className:`body${D?` nav-hidden`:``}${j?` rail-dragging`:``}`,style:{"--rail-w":`${P.current}px`},children:[(0,S.jsx)(us,{tab:ve,onSetTab:ye,fileCount:e.files.length,wantsYou:Et,threadCount:Dt,settledCount:kt,layerCount:ke?On:null,layersSuggested:I?.layersSuggested!==void 0,layers:ke?(0,S.jsx)(cs,{layers:je,activeIndex:He,onPick:Qe,viewed:u,guide:Ie,description:Le,overviewActive:ze,onOpenGuide:Re?$e:void 0,threads:wt,attention:Ct,changed:Ee.changed,selectedPath:En,onPickFile:fn,onToggleFileViewed:un,onMarkFiles:_n,onClearFiles:vn,onAskFile:e=>{it(e),re(e)},onRefresh:Ce?rt:void 0,request:Ce?l:null}):(0,S.jsx)(ls,{state:jn,onOutline:rt,onInvite:()=>z(!0)}),files:(0,S.jsx)(ns,{files:De,viewed:u,selectedPath:En,onPickFile:fn,onToggleFileViewed:un,onMarkFiles:_n,onClearFiles:vn,onAskFile:e=>{it(e),re(e)},threads:wt,attention:Ct,changed:Ee.changed,query:V.query,onQuery:V.setQuery,focusTick:be,hideReviewed:V.hideReviewed,onHideReviewed:V.setHideReviewed,hideTests:V.hideTests,onHideTests:V.setHideTests,onlyChanged:we,onOnlyChanged:Te}),threads:(0,S.jsx)(dd,{items:dt,pastItems:xt,pr:Se!==null,selectedThreadId:Rt,totalThreads:I?.threads.length??0,onOpen:e=>bn(xn(e,e.gone===!0)),onResolve:ee.resolve,onReopen:ee.reopen,onDelete:ee.remove,onClearAll:()=>le(!0)})}),(0,S.jsx)(`div`,{className:`rail-resize`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize file list`,"aria-valuemin":Qd,"aria-valuemax":$d,"aria-valuenow":k,tabIndex:0,"data-tip":`Drag to resize · double-click (or Home) to reset`,onPointerDown:tn,onDoubleClick:nn,onKeyDown:e=>{e.key===`ArrowLeft`?(e.preventDefault(),en(P.current-16)):e.key===`ArrowRight`?(e.preventDefault(),en(P.current+16)):(e.key===`Home`||e.key===`Enter`)&&(e.preventDefault(),nn())}}),(0,S.jsx)(wu,{files:ot,delta:Tn,landed:Jt,sinceReview:Ee.changedHunkIds,hasMore:Ye<qe.length,onLoadMore:Ze,layer:kn,overview:Ge&&ze,controls:{layer:An,navHidden:D,onToggleNav:an,left:g.total-g.viewed,total:g.total,hunksRead:h.viewed,hunksTotal:h.total,hunkAt:y?G.findIndex(e=>e.id===y)+1:0,hunkCount:G.length,query:V.query,onClearQuery:()=>V.setQuery(``),hiddenQuery:Ge?0:V.hiddenQuery,hideReviewed:V.hideReviewed,onHideReviewed:V.setHideReviewed,hideTests:V.hideTests,onHideTests:V.setHideTests,testCount:V.testCount,onlyChanged:V.onlyChanged,onOnlyChanged:V.setOnlyChanged,changedCount:V.changedCount,hiddenTests:Ge?Ke?.hidden??0:V.hiddenTests,hiddenReviewed:Ge?0:V.hiddenReviewed,hiddenUnchanged:Ge?0:V.hiddenUnchanged,pinned:V.pinned,onSweep:V.unpin,onShowAll:V.showAll,scopeLeft:V.scope.left,scopeTotal:V.scope.total,excludedTests:V.scope.excludedTests,excludedUnchanged:V.scope.excludedUnchanged,onIncludeExcluded:()=>{V.scope.excludedTests>0&&V.setHideTests(!1),V.scope.excludedUnchanged>0&&Te(!1)},onFinish:()=>se(!0),stats:e.stats,unsent:W,viewMode:_,onSetViewMode:v,allCollapsed:T.size>=e.files.length&&e.files.length>0,onToggleCollapseAll:()=>E(t=>t.size>=e.files.length?new Set:new Set(e.files.map(e=>e.path)))},viewed:u,onToggleFileViewed:un,selectedId:y,onSelect:b,viewMode:_,collapsed:T,onToggleCollapsed:sn,comments:gn})]}),oe&&(e.pr?(0,S.jsx)(Ou,{coverage:Gt,presence:r,onFinish:$t,onInvite:()=>{se(!1),z(!0)},onClose:()=>se(!1)}):(0,S.jsx)(Pt,{coverage:Gt,presence:r,checkOff:Yt,onResolve:Zt,onReopen:Qt,onFinish:$t,onInvite:()=>{se(!1),z(!0)},onClose:()=>se(!1)})),ce&&(0,S.jsx)(jt,{total:I?.threads.length??0,past:ct.length,outdated:ct.filter(e=>e.github?.outdated===!0).length,onClear:Kt,onClose:()=>le(!1)}),(0,S.jsx)(Ot,{notices:Cn.notices,onOpen:Cn.open,onDismiss:Cn.dismiss,onClear:Cn.clear,onOpenMonitor:()=>bt(!0)}),he.status&&(0,S.jsx)(Qu,{status:he.status,onShown:he.markShown,onAcknowledge:he.acknowledge}),ge&&he.status&&(0,S.jsx)(Vc,{status:he.status,onSetEnabled:he.setEnabled,onClose:()=>_e(!1)}),ue&&(0,S.jsx)(Eu,{onClose:()=>de(!1)}),R&&(0,S.jsx)(lo,{presence:r,reason:i,onClose:()=>z(!1)}),(0,S.jsx)(Bu,{files:e?.files??cf,onJump:mn})]})}):null}function pf(){return(0,S.jsxs)(T,{client:Yd,children:[(0,S.jsx)(Tt,{}),(0,S.jsx)(ff,{})]})}var mf=400,hf=300;function gf(){let e=(0,x.useRef)(null);return(0,x.useEffect)(()=>{let t=e.current;if(!t)return;let n=null,r=!1,i,a=-1/0,o=null,s=()=>{if(!n)return;let e=n.getAttribute(`data-tip`);if(!e){l();return}t.textContent=e;let r=n.getBoundingClientRect(),i=t.offsetWidth,a=t.offsetHeight,o=Math.max(8,Math.min(r.left+r.width/2-i/2,window.innerWidth-i-8)),s=r.top-a-7,c=s<8?r.bottom+7:s;t.style.left=`${Math.round(o)}px`,t.style.top=`${Math.round(c)}px`},c=()=>{n&&(r=!0,o?.disconnect(),o=new MutationObserver(s),o.observe(n,{attributes:!0,attributeFilter:[`data-tip`]}),s(),r&&t.classList.add(`tip-on`))},l=()=>{i!==void 0&&clearTimeout(i),i=void 0,o?.disconnect(),o=null,r&&(a=performance.now()),r=!1,n=null,t.classList.remove(`tip-on`)},u=(e,t)=>{if(e===n)return;let o=r||performance.now()-a<hf;l(),n=e,t||o?c():i=setTimeout(c,mf)},d=e=>{let t=e.target.closest?.(`[data-tip]`);t instanceof HTMLElement?u(t,!1):l()},f=e=>{let t=e.target.closest?.(`[data-tip]`);t instanceof HTMLElement&&t.matches(`:focus-visible`)?u(t,!0):l()},p=()=>{requestAnimationFrame(()=>{n&&!n.isConnected?l():s()})},m=e=>{e.key===`Escape`&&l()};return document.addEventListener(`pointerover`,d,!0),document.addEventListener(`focusin`,f,!0),document.addEventListener(`focusout`,l,!0),document.addEventListener(`click`,p,!0),document.addEventListener(`scroll`,l,!0),document.addEventListener(`keydown`,m,!0),window.addEventListener(`resize`,l),()=>{l(),document.removeEventListener(`pointerover`,d,!0),document.removeEventListener(`focusin`,f,!0),document.removeEventListener(`focusout`,l,!0),document.removeEventListener(`click`,p,!0),document.removeEventListener(`scroll`,l,!0),document.removeEventListener(`keydown`,m,!0),window.removeEventListener(`resize`,l)}},[]),(0,S.jsx)(`div`,{ref:e,className:`tip`,"aria-hidden":`true`})}Od(Ed()),(0,nt.createRoot)(document.getElementById(`root`)).render((0,S.jsxs)(x.StrictMode,{children:[(0,S.jsx)(pf,{}),(0,S.jsx)(gf,{})]}));export{u as a,s as i,fr as n,l as o,o as r,X as t};
92
+ `)}catch{i(e=>e.fingerprint===n?{...e,failed:new Set(e.failed).add(t.key)}:e);return}let s=a.exp.get(t.key)??Gc,c=r===`all`?{fromTop:tl(t),fromBottom:0}:r===`down`?{...s,fromTop:s.fromTop+20}:{...s,fromBottom:s.fromBottom+20},l=il(o,t,s),u=il(o,t,c),d=o;if(u.top.length+u.bottom.length<=l.top.length+l.bottom.length){i(e=>e.fingerprint===n?{...e,headLines:d,failed:new Set(e.failed).add(t.key)}:e);return}i(e=>{if(e.fingerprint!==n)return e;let r=new Set(e.failed);return r.delete(t.key),{...e,headLines:d,exp:new Map(e.exp).set(t.key,c),failed:r}})},s=e=>i(t=>{if(t.fingerprint!==n)return t;let r=new Map(t.exp);r.delete(e.key);let i=new Set(t.failed);return i.delete(e.key),{...t,exp:r,failed:i}}),c=(0,x.useMemo)(()=>{let e=new Map;if(a.headLines===null)return e;for(let n of t){let t=a.exp.get(n.key);t&&e.set(n.key,il(a.headLines,n,t))}return e},[t,a]);return{gaps:t,visible:c,controlsFor:e=>{let t=a.exp.get(e.key)??Gc;return{remaining:nl(e,t),canUp:e.below!==null,canDown:e.above!==null,expanded:t.fromTop+t.fromBottom>0,merged:c.get(e.key)?.merged??!1,failed:a.failed.has(e.key),onUp:()=>void o(e,`up`),onDown:()=>void o(e,`down`),onAll:()=>void o(e,`all`),onCollapse:()=>s(e)}}}}function Cu({file:e,delta:t,sinceReview:n,handlers:r,composerOpen:i=!1,onCloseComposer:a,stub:o=null,onLoadDiff:s}){let c=e.status!==`deleted`&&e.kind===`text`,{gaps:l,visible:u,controlsFor:d}=Su(e),f=r.comments,p=f?.partition.byFile.get(e.path)??[],m=e.path.slice(e.path.lastIndexOf(`/`)+1),h=t=>t?{kind:`changeset`}:{kind:`file`,path:e.path},g=f&&(p.length>0||i)&&(0,S.jsxs)(`div`,{className:`file-threads`,children:[(0,S.jsx)(Ic,{threads:p,actions:f.actions,showContext:!0,agentConnected:f.agentConnected,workingOn:f.workingOn,queuedOn:f.queuedOn}),i&&(0,S.jsx)(bc,{title:`Comment on ${m}`,placeholder:`Leave a comment…`,scope:{label:m,canWiden:!0},agentConnected:f.agentConnected,onSubmit:(e,t,n,r)=>{r?f.actions.create(h(t),e,n,{audience:r}):f.actions.create(h(t),e,n),a?.()},onSend:(e,t,n)=>{f.actions.create(h(t),e,n).then(e=>f.actions.send(e.id)),a?.()},onCancel:()=>a?.()})]});if(o!==null)return(0,S.jsxs)(S.Fragment,{children:[g,(0,S.jsxs)(`div`,{className:`file-stub file-stub-large`,children:[(0,S.jsx)(`span`,{children:o===`generated`?`Generated file, not rendered by default.`:`Large diff (${Uc(e)} changed lines), not rendered by default.`}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:s,children:`Load diff`})]})]});if(e.kind===`image`&&e.hunks.length===0)return(0,S.jsxs)(S.Fragment,{children:[g,(0,S.jsx)(cu,{file:e})]});if(e.kind===`binary`)return(0,S.jsxs)(S.Fragment,{children:[g,(0,S.jsx)(`div`,{className:`file-stub`,children:`binary file changed`})]});if(e.hunks.length===0)return(0,S.jsxs)(S.Fragment,{children:[g,(0,S.jsx)(`div`,{className:`file-stub`,children:e.status===`renamed`?`renamed, no content changes`:`no content changes`})]});let _=po(e,r.viewed),v=new Map,y=new Map;for(let e of l)e.below!==null&&v.set(e.below,e),e.above!==null&&y.set(e.above,e);let b=l.find(e=>e.below===null);return(0,S.jsxs)(S.Fragment,{children:[g,e.kind===`image`&&(0,S.jsx)(cu,{file:e}),e.hunks.map((e,i)=>{let a=c?v.get(i):void 0,o=c?y.get(i):void 0;return(0,S.jsx)(ou,{hunk:e,fresh:t.freshHunkIds.has(e.id),changedSinceReview:n?.has(e.id)??!1,changedSinceViewed:t.changedViewedHunkIds.has(e.id),viewed:_,selected:r.selectedId===e.id,onSelect:r.onSelect,viewMode:r.viewMode??`unified`,linesAbove:a&&u.get(a.key)?.bottom,linesBelow:o&&u.get(o.key)?.top,gapAbove:a?d(a):null,threads:f?.partition.byHunk.get(e.id),reviewActions:f?.actions,agentConnected:f?.agentConnected,workingOn:f?.workingOn,queuedOn:f?.queuedOn,composeRequested:f?.composeHunkId===e.id,onComposeHandled:f?.onComposeHandled},e.id)}),c&&b&&(0,S.jsx)(Yl,{gap:d(b)})]})}function wu({files:e,delta:t=al,sinceReview:n,hasMore:r=!1,onLoadMore:i,controls:a,landed:o,layer:s,overview:c=!1,...l}){let[u,d]=(0,x.useState)(null),[f,p]=(0,x.useState)(!1),[m,h]=(0,x.useState)(new Set),g=l.selectedId;(0,x.useEffect)(()=>{if(!g)return;let t=e.find(e=>e.hunks.some(e=>e.id===g));t&&Wc(t)!==null&&h(e=>e.has(t.path)?e:new Set(e).add(t.path))},[g,e]);let _=(0,x.useRef)(null),v=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(!r||!i)return;if(typeof IntersectionObserver>`u`){i();return}let e=v.current;if(!e)return;let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&i()},{root:_.current,rootMargin:`1200px 0px`});return t.observe(e),()=>t.disconnect()},[r,i,e.length]);let y=(0,x.useRef)({files:e,controls:a,viewed:l.viewed});y.current={files:e,controls:a,viewed:l.viewed};let b=(0,x.useRef)(0);(0,x.useEffect)(()=>{let e=_.current;if(!e)return;let t=0,n=()=>{t=0;let{files:n,controls:r,viewed:i}=y.current;if(!r?.hideReviewed||r.pinned.size===0)return;let a=(e.querySelector(`.pane-bar`)??e).getBoundingClientRect().bottom;for(let e of n){if(!r.pinned.has(e.path)||!po(e,i))continue;let t=document.getElementById(zo(e.path));if(!t)continue;let n=t.getBoundingClientRect();n.bottom>=a||(b.current+=n.height+(parseFloat(getComputedStyle(t).marginBottom)||0),r.onSweep(e.path))}},r=()=>{t!==0&&cancelAnimationFrame(t),t=requestAnimationFrame(n)};return e.addEventListener(`scroll`,r,{passive:!0}),()=>{e.removeEventListener(`scroll`,r),t!==0&&cancelAnimationFrame(t)}},[]),(0,x.useLayoutEffect)(()=>{let e=_.current;e&&b.current!==0&&(e.scrollTop-=b.current,b.current=0)});let C=l.comments?.composeFilePath??null;(0,x.useEffect)(()=>{C&&(l.collapsed?.has(C)&&l.onToggleCollapsed?.(C),d(C),l.comments?.onComposeFileHandled?.())},[C]);let[w,T]=(0,x.useState)(null),E=w??s===void 0,D=T,O=l.comments,k=O?.revealNotesTick??0;(0,x.useEffect)(()=>{k>0&&D(!0)},[k]);let A=c||E||O?.changesetComposerOpen===!0,j=c||s===void 0,[M,N]=(0,x.useState)(!1),P=O?.revealPastTick??0;(0,x.useEffect)(()=>{P>0&&N(!0)},[P]);let F=fs(),I=O?.partition.changeset.length??0,ee=F?.viewer.login??null,te=O?.partition.changeset,{lead:ne,others:L}=(0,x.useMemo)(()=>{let e=te??[];if(!F)return{lead:e,others:[]};let t=e=>e.github?.kind===`description`||!it(e)||Cs(e,ee);return{lead:e.filter(t),others:e.filter(e=>!t(e))}},[te,F,ee]),[re,ie]=(0,x.useState)(!1),ae=O?.revealThreadId??null;(0,x.useEffect)(()=>{k>0&&ae!==null&&L.some(e=>e.id===ae)&&ie(!0)},[k,ae,L]);let oe=O&&j&&(I>0||O.changesetComposerOpen||c)&&(0,S.jsxs)(`section`,{className:`changeset-strip`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`strip-head`,onClick:()=>D(!E),"aria-expanded":A,children:[(0,S.jsx)(`span`,{className:`file-chevron chevron${A?``:` chevron-shut`}`,children:(0,S.jsx)(U,{name:`chev`})}),F?`On the pull request`:`On the changeset`,(0,S.jsx)(`span`,{className:`strip-n`,children:I})]}),A&&(0,S.jsxs)(`div`,{className:`strip-body`,children:[(0,S.jsx)(Ic,{threads:ne,actions:O.actions,showContext:!0,agentConnected:O.agentConnected,workingOn:O.workingOn,queuedOn:O.queuedOn,links:O.links}),L.length>0&&(0,S.jsx)(`button`,{type:`button`,className:`strip-more`,"aria-expanded":re,onClick:()=>ie(!re),children:re?`Only mine`:`${L.length} more from others`}),re&&L.length>0&&(0,S.jsx)(Ic,{threads:L,actions:O.actions,showContext:!0,agentConnected:O.agentConnected,workingOn:O.workingOn,queuedOn:O.queuedOn,links:O.links}),O.changesetComposerOpen?(0,S.jsx)(bc,{title:`Note on the whole changeset`,placeholder:`Leave a note…`,scope:{label:`the whole changeset`,canWiden:!1},agentConnected:O.agentConnected,onSubmit:(e,t,n,r)=>{r?O.actions.create({kind:`changeset`},e,n,{audience:r}):O.actions.create({kind:`changeset`},e,n),O.onCloseChangesetComposer?.()},onSend:(e,t,n)=>{O.actions.create({kind:`changeset`},e,n).then(e=>O.actions.send(e.id)),O.onCloseChangesetComposer?.()},onCancel:()=>O.onCloseChangesetComposer?.()}):O.onOpenChangesetComposer&&(0,S.jsx)(`button`,{type:`button`,className:`strip-add`,onClick:O.onOpenChangesetComposer,children:F?`+ Comment on the pull request`:`+ Note on the changeset`})]})]}),se=O?.past??[],ce=se.filter(e=>e.github?.outdated===!0).length,le=se.filter(e=>e.anchor.kind===`layer`).length,ue=le===se.length?`The layer ${se.length===1?`this hangs`:`these hang`} off left the outline: the agent re-posted without ${se.length===1?`its`:`their`} title.`:ce===se.length?`${se.length===1?`This one is`:`These are`} outdated on GitHub: the line ${se.length===1?`it hangs`:`they hang`} off left the diff, though the file is still in it.`:ce>0?`The file or change these hang off is no longer in the diff: reverted, deleted, or stashed; ${ce} ${ce===1?`is`:`are`} outdated on GitHub instead, the line left the diff.`:`The file or change these hang off is no longer in the diff: reverted, deleted, or stashed.`,de=O&&se.length>0&&(0,S.jsxs)(`section`,{className:`file-section past-threads`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`file-header notes-header`,onClick:()=>N(e=>!e),"aria-expanded":M,children:[(0,S.jsx)(`span`,{className:`file-chevron chevron${M?``:` chevron-shut`}`,children:(0,S.jsx)(U,{name:`chev`})}),(0,S.jsxs)(`span`,{className:`file-path`,children:[se.length===1?`1 thread`:`${se.length} threads`,` whose`,` `,le===se.length?`layer left the outline`:`code left the changeset`]})]}),M&&(0,S.jsxs)(`div`,{className:`file-threads`,children:[(0,S.jsxs)(`div`,{className:`past-hint`,children:[ue,` The conversation is intact`,le===se.length?`.`:`, and the snapshot inside each one is the code you commented on.`]}),(0,S.jsx)(Ic,{threads:se,actions:O.actions,showContext:!0,gone:!0,agentConnected:O.agentConnected,workingOn:O.workingOn,queuedOn:O.queuedOn})]})]}),R=a?.total??0,z=e.length===0&&R===0,B=e.length===0&&R>0,fe=a!==void 0&&a.scopeTotal>0&&a.scopeLeft===0;(0,x.useEffect)(()=>{fe&&p(!1)},[fe]);let pe=(a?.hiddenTests??0)+(a?.hiddenReviewed??0)+(a?.hiddenUnchanged??0)+(a?.hiddenQuery??0),me=a&&(0,S.jsx)(mu,{read:a.total-a.left,total:a.total,excludedTests:a.excludedTests,excludedUnchanged:a.excludedUnchanged,stats:a.stats,unsent:a.unsent,onFinish:a.onFinish,onIncludeExcluded:a.onIncludeExcluded,onDismiss:()=>p(!0),shape:B?`full`:`docked`}),he=c?null:z?o?(0,S.jsx)(_u,{...o,shape:`full`}):(0,S.jsxs)(`div`,{className:`empty-state`,children:[(0,S.jsx)(U,{name:`book`,size:`lg`}),(0,S.jsx)(`h2`,{children:`Nothing to review`}),(0,S.jsx)(`p`,{children:`The working tree is clean. Diffo is watching; start your agent and changes appear here as they land.`})]}):s&&e.length===0?(0,S.jsx)(vu,{layer:s,filesShown:0,comments:O}):B&&fe?me:B&&a?(0,S.jsxs)(`div`,{className:`empty-state`,children:[(0,S.jsx)(U,{name:`filter`,size:`lg`}),(0,S.jsxs)(`h2`,{children:[a.left,` `,a.left===1?`file`:`files`,` still to review`]}),(0,S.jsx)(`p`,{children:a.hiddenQuery===0?`They're hidden by the switches on the bar above.`:a.hiddenTests+a.hiddenReviewed+a.hiddenUnchanged===0?`None of them match “${a.query.trim()}”.`:`They're hidden by “${a.query.trim()}” and the switches on the bar above.`}),(0,S.jsx)(`div`,{className:`empty-acts`,children:(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:a.onShowAll,children:`Show all files`})})]}):(0,S.jsxs)(S.Fragment,{children:[s&&(0,S.jsx)(vu,{layer:s,filesShown:e.length,comments:O}),e.map(e=>{let r=l.collapsed?.has(e.path)??!1,i=O?.partition.byFile.get(e.path)?.length??0,a=O===void 0?0:e.hunks.reduce((e,t)=>e+(O.partition.byHunk.get(t.id)?.length??0),0),o=g!=null&&e.hunks.some(e=>e.id===g),c=m.has(e.path)||o||a>0?null:Wc(e),f=n===void 0?0:e.hunks.reduce((e,t)=>e+ +!!n.has(t.id),0);return(0,S.jsxs)(`section`,{id:zo(e.path),className:`file-section${r?` file-section-collapsed`:``}`,children:[(0,S.jsx)(bu,{file:e,viewed:l.viewed,collapsed:r,onToggle:()=>l.onToggleCollapsed?.(e.path),commentCount:i+a,sinceCount:f,note:s?.notes.get(e.path),onToggleFileViewed:l.onToggleFileViewed?()=>l.onToggleFileViewed(e.path):void 0,onComment:O?()=>{r&&l.onToggleCollapsed?.(e.path),d(t=>t===e.path?null:e.path)}:void 0}),!r&&(0,S.jsx)(Cu,{file:e,delta:t,sinceReview:n,handlers:l,composerOpen:u===e.path,onCloseComposer:()=>d(null),stub:c,onLoadDiff:()=>h(t=>new Set(t).add(e.path))})]},e.path)}),r&&(0,S.jsxs)(`div`,{ref:v,className:`load-more`,"aria-hidden":`true`,children:[(0,S.jsx)(`div`,{className:`shimmer`}),(0,S.jsx)(`div`,{className:`shimmer shimmer-short`})]}),a&&pe>0&&(0,S.jsxs)(`div`,{className:`pane-hidden`,children:[(0,S.jsxs)(`span`,{className:`pane-hidden-said`,children:[(0,S.jsx)(U,{name:`eye-off`,size:`sm`}),[a.hiddenQuery>0?`${a.hiddenQuery} not matching “${a.query.trim()}”`:null,a.hiddenUnchanged>0?`${a.hiddenUnchanged} unchanged`:null,a.hiddenTests>0?`${a.hiddenTests} test${a.hiddenTests===1?``:`s`}`:null,a.hiddenReviewed>0?`${a.hiddenReviewed} reviewed`:null].filter(Boolean).join(`, `),` `,`hidden`]}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:a.onShowAll,children:`Show all files`})]})]});return(0,S.jsxs)(`div`,{className:`reading-pane${a?` reading-pane-barred`:``}`,ref:_,children:[a&&(0,S.jsx)(du,{navHidden:a.navHidden,onToggleNav:a.onToggleNav,left:a.left,total:a.total,hunksRead:a.hunksRead,hunksTotal:a.hunksTotal,hunkAt:a.hunkAt,hunkCount:a.hunkCount,query:a.query,onClearQuery:a.onClearQuery,hideReviewed:a.hideReviewed,onHideReviewed:a.onHideReviewed,hideTests:a.hideTests,onHideTests:a.onHideTests,testCount:a.testCount,onlyChanged:a.onlyChanged,onOnlyChanged:a.onOnlyChanged,changedCount:a.changedCount,viewMode:a.viewMode,onSetViewMode:a.onSetViewMode,allCollapsed:a.allCollapsed,onToggleCollapseAll:a.onToggleCollapseAll,stats:a.stats,layer:a.layer}),(0,S.jsxs)(`div`,{className:`reading-col`,children:[o&&!z&&(0,S.jsx)(_u,{...o,shape:`docked`}),oe,de,he]}),fe&&!B&&!f&&me]})}var Tu=[{name:`Move`,keys:[[`j`,`Next hunk`],[`k`,`Previous hunk`],[`J`,`Next file`],[`K`,`Previous file`],[`n`,`Next unreviewed file`],[`]`,`Next layer`],[`[`,`Previous layer`],[`.`,`Next decision in this layer`],[`/`,`Filter files`]]},{name:`Read`,keys:[[`v`,`Mark this file reviewed`],[`h`,`Hide reviewed files`],[`u`,`Unified / split`],[`o`,`Collapse / expand file`],[`b`,`Show / hide the file list`]]},{name:`Comment`,keys:[[`c`,`Comment on the clicked line, else this hunk`],[`drag ↓`,`Comment on a range of lines`],[`⇧ click`,`Move the range’s edge to a line`],[`⌘↵`,`Add the comment`],[`esc`,`Close / cancel`],[`?`,`This sheet`]]}];function Eu({onClose:e}){return(0,S.jsx)(At,{title:`Shortcuts`,onClose:e,children:(0,S.jsx)(`div`,{className:`keys`,children:Tu.map(e=>(0,S.jsxs)(`div`,{className:`keys-group`,children:[(0,S.jsx)(`div`,{className:`keys-name`,children:e.name}),e.keys.map(([e,t])=>(0,S.jsxs)(`div`,{className:`keys-row`,children:[(0,S.jsx)(`span`,{className:`kbd`,children:e}),` `,t]},e))]},e.name))})})}var Du={COMMENT:`Commented`,APPROVE:`Approved`,REQUEST_CHANGES:`Changes requested`};function Ou({coverage:e,presence:t,onFinish:n,onInvite:r,onClose:i}){let a=fs(),o=xt(!0,e),s=(0,x.useRef)(null),[c,l]=(0,x.useState)(``),[u,d]=(0,x.useState)(`write`),[f,p]=(0,x.useState)(`COMMENT`),[m,h]=(0,x.useState)(!1),[g,_]=(0,x.useState)(!1),[v,y]=(0,x.useState)(null),[b,C]=(0,x.useState)(null),[w,T]=(0,x.useState)(!1),E=t!==`waiting`,D=o.data?.public,O=o.data?.outgoing??[],k=D?D.drafts.length+D.replies.length+D.resolves.length:0,A=a!==null&&a.state!==`open`,j=k>0||f!==`COMMENT`||c.trim()!==``||o.isError,M=()=>{j&&!m&&(_(!1),y(null),h(!0),n(!0,{note:c,event:f}).then(({delivered:e,public:t})=>{if(t?.failed){y(t.failed),o.refetch();return}C(t??{posted:0,resolved:0,submitted:!1,reviewId:null}),T(e)}).catch(()=>_(!0)).finally(()=>h(!1)))},N=[[`COMMENT`,`Comment`,`Submit general feedback without explicit approval.`],[`APPROVE`,`Approve`,`Submit feedback and approve merging these changes.`],[`REQUEST_CHANGES`,`Request changes`,`Submit feedback suggesting changes.`]],P=A?`${a.state===`merged`?`Merged`:`Closed`} already: GitHub takes comments, not verdicts.`:D&&!D.canApprove?`Your own pull request: GitHub does not let you approve or block it.`:null;(0,x.useEffect)(()=>{f!==`COMMENT`&&P!==null&&p(`COMMENT`)},[f,P]);let F=O.length>0?`${O.length} private ${O.length===1?`thread`:`threads`} and your coverage`:`your coverage`,I=b?(0,S.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:i,children:`Done`}):(0,S.jsxs)(S.Fragment,{children:[o.data&&(0,S.jsxs)(`span`,{className:`sub-agent${E?``:` sub-agent-off`}`,children:[(0,S.jsx)(U,{name:E?`lock`:`alert`,size:`sm`}),(0,S.jsx)(`span`,{className:`sub-agent-text`,children:E?(0,S.jsxs)(S.Fragment,{children:[`Also, privately: `,F,` go to your agent`]}):(0,S.jsxs)(S.Fragment,{children:[`No agent attached: `,F,` wait for one.`,` `,(0,S.jsx)(`button`,{type:`button`,className:`fin-link`,onClick:r,children:`Invite one`})]})})]}),(0,S.jsx)(`span`,{className:`grow`}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:m,onClick:i,children:`Cancel`}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-gh${m?` btn-busy`:``}`,disabled:!j||m,"aria-busy":m,title:j?`post this review on GitHub, #${a?.number??``} (⌘↵)`:`nothing for GitHub yet: write a comment, pick a verdict, or draft a review comment`,onClick:M,children:m?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`spin`,"aria-hidden":`true`}),` Submitting to GitHub`]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(U,{name:`globe`,size:`sm`}),` Submit to GitHub `,(0,S.jsx)(`kbd`,{className:`sub-kbd`,children:`⌘↵`})]})})]});return(0,S.jsxs)(At,{title:b?`Review submitted to GitHub`:`Submit review to GitHub`,wide:!0,className:`sub-modal`,onClose:i,footer:I,children:[a&&(0,S.jsxs)(`div`,{className:`sub-where`,children:[(0,S.jsx)(U,{name:`pr`,size:`sm`}),(0,S.jsxs)(`span`,{className:`sub-where-repo`,children:[`one review on `,a.owner,`/`,a.repo,` #`,a.number]}),(0,S.jsx)(`span`,{className:`sub-where-title`,children:a.title})]}),!b&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`sub-editor`,children:[(0,S.jsxs)(`div`,{className:`sub-editor-bar`,children:[(0,S.jsx)(`div`,{className:`cbox-tabs sub-tabs`,role:`tablist`,children:[`write`,`preview`].map(e=>(0,S.jsx)(`button`,{type:`button`,role:`tab`,className:`cbox-tab`,"aria-selected":u===e,onClick:()=>d(e),children:e===`write`?`Write`:`Preview`},e))}),u===`write`&&(0,S.jsx)(`div`,{className:`sub-tools`,children:gc.map((e,t)=>e===`sep`?(0,S.jsx)(`span`,{className:`cbox-mdsep`},t):(0,S.jsx)(`button`,{type:`button`,className:`cbox-mdb`,"data-tip":e.label,"aria-label":e.label,onClick:()=>s.current&&yc(s.current,e,l),children:(0,S.jsx)(U,{name:e.icon,size:`sm`})},t))})]}),u===`write`?(0,S.jsx)(`textarea`,{ref:s,autoFocus:!0,className:`sub-body`,placeholder:`Leave a comment`,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),M())}}):c.trim()?(0,S.jsx)(pc,{className:`sub-preview markdown`,text:c}):(0,S.jsx)(`div`,{className:`sub-preview sub-preview-empty`,children:`Nothing to preview`})]}),(0,S.jsx)(`div`,{className:`sub-verdicts`,role:`radiogroup`,"aria-label":`Your verdict`,children:N.map(([e,t,n])=>{let r=e!==`COMMENT`&&P!==null;return(0,S.jsxs)(`label`,{className:`sub-verdict${f===e?` sub-verdict-on`:``}${r?` sub-verdict-off`:``}`,children:[(0,S.jsx)(`input`,{type:`radio`,name:`verdict`,value:e,checked:f===e,disabled:r,onChange:()=>p(e)}),(0,S.jsxs)(`span`,{className:`sub-verdict-text`,children:[(0,S.jsx)(`b`,{children:t}),(0,S.jsx)(`small`,{className:r?`sub-verdict-why`:void 0,children:r?P:n})]})]},e)})}),(0,S.jsxs)(`div`,{className:`fin-sect`,children:[(0,S.jsxs)(`div`,{className:`fin-sect-h`,children:[(0,S.jsx)(`span`,{className:`fin-sect-label`,children:`Pending`}),D&&(0,S.jsx)(`span`,{className:`fin-sect-n`,children:k}),(0,S.jsx)(`span`,{className:`fin-sect-why`,children:o.isLoading?`· loading`:o.error||!D?`· could not load what is pending; the review still submits`:k>0?`· post to GitHub with this review; nothing has posted yet`:`· nothing drafted; a comment above still submits a review to GitHub`})]}),D&&k>0&&(0,S.jsxs)(`ul`,{className:`sub-pending`,children:[D.drafts.map(e=>(0,S.jsxs)(`li`,{className:`sub-pending-row`,children:[(0,S.jsxs)(`div`,{className:`sub-pending-at`,children:[(0,S.jsx)(`span`,{className:`sub-pending-kind`,children:e.conversation?`comment`:`review comment`}),(0,S.jsx)(`span`,{className:`sub-pending-anchor`,children:e.anchor}),e.fromAgent&&(0,S.jsxs)(`span`,{className:`fin-row-note sub-pending-origin`,title:`your agent wrote the first version; it posts as yours`,children:[`from your agent`,e.fromAgent.edited&&`, edited`]}),e.downgraded&&(0,S.jsx)(`span`,{className:`fin-row-note`,title:`GitHub only takes comments on lines in its diff`,children:`line not in the diff; posts on the file`})]}),(0,S.jsx)(`div`,{className:`sub-pending-text`,children:e.text})]},e.id)),D.replies.map(e=>(0,S.jsxs)(`li`,{className:`sub-pending-row`,children:[(0,S.jsxs)(`div`,{className:`sub-pending-at`,children:[(0,S.jsx)(`span`,{className:`sub-pending-kind`,children:e.count===1?`reply`:`${e.count} replies`}),(0,S.jsx)(`span`,{className:`sub-pending-anchor`,children:e.anchor})]}),(0,S.jsx)(`div`,{className:`sub-pending-text`,children:e.text})]},e.id)),D.resolves.map(e=>(0,S.jsx)(`li`,{className:`sub-pending-row`,children:(0,S.jsxs)(`div`,{className:`sub-pending-at`,children:[(0,S.jsx)(`span`,{className:`sub-pending-kind`,children:e.resolve?`resolve`:`reopen`}),(0,S.jsx)(`span`,{className:`sub-pending-anchor`,children:e.anchor})]})},e.id))]}),D&&(D.undecidedSuggestions??0)>0&&(0,S.jsx)(`p`,{className:`sub-undecided`,role:`note`,children:D.undecidedSuggestions===1?`One suggested comment from your agent is still undecided. It stays private and never posts.`:`${D.undecidedSuggestions} suggested comments from your agent are still undecided. They stay private and never post.`})]})]}),b&&(0,S.jsxs)(`div`,{className:`sub-done`,children:[(0,S.jsxs)(`div`,{className:`sub-done-card`,children:[(0,S.jsx)(`span`,{className:`sub-done-mark`,"aria-hidden":`true`,children:(0,S.jsx)(U,{name:`check`,size:`md`})}),(0,S.jsxs)(`div`,{className:`sub-done-text`,children:[(0,S.jsx)(`b`,{children:b.submitted?Du[f]:`Review finished`}),(0,S.jsx)(`span`,{className:`sub-done-detail`,children:[b.posted>0&&`${b.posted} ${b.posted===1?`comment`:`comments`} posted`,b.resolved>0&&`${b.resolved} ${b.resolved===1?`thread`:`threads`} resolved`].filter(Boolean).join(` · `)||`on #${a?.number??``}`})]}),b.url&&(0,S.jsxs)(`a`,{className:`btn btn-sm btn-outline`,href:b.url,target:`_blank`,rel:`noreferrer`,children:[`Open on GitHub `,(0,S.jsx)(U,{name:`link`,size:`sm`})]})]}),(0,S.jsxs)(`p`,{className:`sub-done-agent`,children:[(0,S.jsx)(U,{name:`lock`,size:`sm`}),w?`Private threads and coverage went to your agent.`:`Private threads and coverage go to your agent on its next poll.`]})]}),v&&(0,S.jsxs)(`div`,{className:`warn`,children:[(0,S.jsx)(U,{name:`alert`,size:`sm`}),(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`b`,{children:[`GitHub stopped at `,v.step]}),`: `,v.message,`. What posted before it is recorded and will not post twice; nothing went to your agent. Fix the cause and submit again.`]})]}),g&&(0,S.jsx)(`p`,{className:`cov-note cov-note-error`,children:`Couldn't submit; the server may be down. Nothing was sent; try again.`})]})}var ku={showDelay:600,leaveGrace:500},Au=class{hooks;timing;armed=null;shown=null;showTimer;hideTimer;constructor(e,t=ku){this.hooks=e,this.timing=t}over(e){if(this.shown&&this.hooks.same(e,this.shown)){this.cancelHide();return}this.armed&&this.hooks.same(e,this.armed)||(this.shown&&this.leave(),this.cancelShow(),this.armed=e,this.showTimer=setTimeout(()=>{this.showTimer=void 0,this.armed=null,this.shown=e,this.hooks.show(e)},this.timing.showDelay))}inCard(){this.cancelHide(),this.cancelShow()}away(){this.cancelShow(),this.leave()}dismiss(){this.cancelShow(),this.cancelHide(),this.close()}get isShown(){return this.shown!==null}leave(){this.shown&&this.hideTimer===void 0&&(this.hideTimer=setTimeout(()=>{this.hideTimer=void 0,this.close()},this.timing.leaveGrace))}close(){this.shown&&(this.shown=null,this.hooks.hide())}cancelShow(){this.showTimer!==void 0&&clearTimeout(this.showTimer),this.showTimer=void 0,this.armed=null}cancelHide(){this.hideTimer!==void 0&&clearTimeout(this.hideTimer),this.hideTimer=void 0}},ju=/[A-Za-z_$][\w$]*/g;function Mu(e,t){ju.lastIndex=0;for(let n of e.matchAll(ju)){let e=n.index,r=e+n[0].length;if(t<e)return null;if(t<=r)return{word:n[0],start:e,end:r}}return null}var Nu=new Set(`abstract and as assert async await begin bool boolean break case catch chan char class const continue crate debugger decimal def default defer del delete do done double dyn elif else elsif end ensure enum esac except export extends extern fallthrough false fi final finally float fn for from func function global go goto if impl implements import in include instanceof int interface internal is lambda let local long loop match mod module move mut namespace native new nil nonlocal not null of or override package pass private protected pub public raise readonly ref require rescue return satisfies sealed select self short signed sizeof static struct super switch template then this throw throws trait transient true try type typedef typename typeof undefined union unless unsigned until use using var virtual void volatile where while with yield None True False Self`.split(` `));function Pu(e){return e.length>0&&!Nu.has(e)}function Fu(e,t){return t===`base`?e!==`add`:e!==`del`}function Iu(e){return e.replace(/[$\\]/g,`\\$&`)}function Lu(e,t,n){if(!t)return[];let r=RegExp(`(?<![\\w$])${Iu(t)}(?![\\w$])`),i=[];for(let t of e){if(t.kind!==`text`)continue;let e=[];for(let i of t.hunks)for(let a of i.lines){if(!Fu(a.kind,n))continue;let o=n===`base`?a.oldNo:a.newNo;if(o===null)continue;let s=r.exec(a.text);s&&e.push({path:t.path,hunkId:i.id,line:o,text:a.text,col:s.index})}e.length!==0&&(e.sort((e,t)=>e.line-t.line),i.push({path:t.path,usages:e}))}return i}function Ru(e){return e.reduce((e,t)=>e+t.usages.length,0)}var zu=`sym-occ`;function Bu({files:e,onJump:t}){let[n,r]=(0,x.useState)(null),i=(0,x.useRef)(null),a=(0,x.useRef)(()=>{}),o=(0,x.useMemo)(()=>{let t=new Map;for(let n of e)for(let e of n.hunks)t.set(e.id,n.path);return t},[e]),s=(0,x.useRef)(o);s.current=o,(0,x.useEffect)(()=>{let e=new Au({same:(e,t)=>e.cell===t.cell&&e.start===t.start&&e.word===t.word,show:e=>{Z(e.word,e.side),r(e)},hide:()=>{Q(),r(null)}}),t=e=>i.current!==null&&e instanceof Node&&i.current.contains(e),n=n=>{if(t(n.target)){e.inCard();return}let r=n.target instanceof Element?n.target:null,i=r?Xu(r,n.clientX,n.clientY,s.current):null;i?e.over(i):e.away()},o=()=>e.dismiss(),c=e=>{e.key===`Escape`&&o()},l=e=>{t(e.target)||o()},u=e=>{t(e.target)||o()};return a.current=o,document.addEventListener(`mousemove`,n,!0),document.addEventListener(`mousedown`,l,!0),document.addEventListener(`scroll`,u,!0),document.addEventListener(`keydown`,c,!0),window.addEventListener(`resize`,o),window.addEventListener(`blur`,o),()=>{o(),document.removeEventListener(`mousemove`,n,!0),document.removeEventListener(`mousedown`,l,!0),document.removeEventListener(`scroll`,u,!0),document.removeEventListener(`keydown`,c,!0),window.removeEventListener(`resize`,o),window.removeEventListener(`blur`,o)}},[]);let c=(0,x.useMemo)(()=>n?Lu(e,n.word,n.side):[],[e,n]);return(0,x.useLayoutEffect)(()=>{let e=i.current;if(!e||!n)return;let t=Yu(n.cell,n.start,n.end)?.getBoundingClientRect();if(!t)return;let r=e.offsetWidth,a=e.offsetHeight,o=Math.max(8,Math.min(t.left-10,window.innerWidth-r-8)),s=t.top-a-4,c=s>=8?s:Math.min(t.bottom+4,window.innerHeight-a-8);e.style.left=`${Math.round(o)}px`,e.style.top=`${Math.round(c)}px`,e.dataset.place=s>=8?`above`:`below`,e.classList.add(`sym-card-on`)},[n]),n?(0,S.jsx)(`div`,{ref:i,className:`sym-card`,role:`dialog`,"aria-label":`usages of ${n.word}`,children:(0,S.jsx)(Vu,{word:n.word,side:n.side,groups:c,here:n.line===null?null:{hunkId:n.hunkId,line:n.line},onJump:e=>{a.current(),t(e)}},`${n.side}:${n.word}`)}):null}function Vu({word:e,side:t,groups:n,here:r,onJump:i}){let[a,o]=(0,x.useState)(()=>new Set),s=e=>o(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),c=Ru(n),l=r?Math.max(0,c-1):c;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`sym-card-head`,children:[(0,S.jsx)(`code`,{className:`sym-card-word`,children:e}),(0,S.jsxs)(`span`,{className:`sym-card-count`,children:[l===0?`nowhere else in this change`:`${l} other ${l===1?`usage`:`usages`}`,t===`base`&&(0,S.jsx)(`span`,{className:`sym-card-side`,children:`before`})]})]}),c>0&&(0,S.jsx)(`div`,{className:`sym-card-list`,children:n.map(e=>{let n=a.has(e.path),o=r?e.usages.filter(e=>Hu(e,r)).length:0;return(0,S.jsxs)(`div`,{className:`sym-card-file`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`sym-card-path`,"aria-expanded":n,title:e.path,onClick:()=>s(e.path),children:[(0,S.jsx)(U,{name:`chev`,size:`sm`}),(0,S.jsx)(Uu,{path:e.path}),(0,S.jsxs)(`span`,{className:`sym-card-n`,children:[e.usages.length-o,o>0&&(0,S.jsx)(`span`,{className:`sym-card-n-here`,children:` + here`})]})]}),n&&e.usages.map(e=>{let n=r!==null&&Hu(e,r);return(0,S.jsxs)(`button`,{type:`button`,className:`sym-card-row${n?` sym-card-here`:``}`,"aria-current":n?`location`:void 0,onClick:()=>i({path:e.path,side:t,line:e.line}),children:[(0,S.jsx)(`span`,{className:`sym-card-ln`,children:e.line}),(0,S.jsx)(Gu,{usage:e})]},`${e.hunkId}:${e.line}`)})]},e.path)})})]})}function Hu(e,t){return e.hunkId===t.hunkId&&e.line===t.line}function Uu({path:e}){let t=e.lastIndexOf(`/`);return t===-1?(0,S.jsx)(`span`,{className:`sym-card-name`,children:e}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`sym-card-name`,children:e.slice(t+1)}),(0,S.jsx)(`span`,{className:`sym-card-dir`,children:e.slice(0,t)})]})}var Wu=28;function Gu({usage:e}){let t=e.text,n=t.search(/\S|$/),r=!1;e.col-n>Wu&&(n=t.lastIndexOf(` `,e.col-Wu+8)+1,(n<=0||e.col-n>56)&&(n=e.col-Wu),r=!0);let i=t.slice(n,e.col),a=t.slice(e.col,e.col+Ku(t,e.col)),o=t.slice(e.col+a.length);return(0,S.jsxs)(`span`,{className:`sym-card-code`,children:[r&&(0,S.jsx)(`span`,{className:`sym-card-ellipsis`,children:`…`}),i,(0,S.jsx)(`mark`,{children:a}),o]})}function Ku(e,t){let n=Mu(e,t);return n&&n.start===t?n.end-t:0}function qu(e,t){let n=document;if(n.caretPositionFromPoint){let r=n.caretPositionFromPoint(e,t);return r?{node:r.offsetNode,offset:r.offset}:null}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);return r?{node:r.startContainer,offset:r.startOffset}:null}return null}function Ju(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let e=n.nextNode();e;e=n.nextNode())t.push(e);return t}function Yu(e,t,n){let r=document.createRange(),i=0,a=!1;for(let o of Ju(e)){let e=o.data.length;if(!a&&t<i+e&&(r.setStart(o,t-i),a=!0),a&&n<=i+e)return r.setEnd(o,n-i),r;i+=e}return null}function Xu(e,t,n,r){let i=e.closest?.(`td[data-side]`);if(!(i instanceof HTMLElement)||e.closest(`.nosym`))return null;let a=qu(t,n);if(!a||a.node.nodeType!==Node.TEXT_NODE||!i.contains(a.node))return null;let o=a.offset;for(let e of Ju(i)){if(e===a.node)break;o+=e.data.length}let s=Mu(i.textContent??``,o);if(!s||!Pu(s.word))return null;let c=Yu(i,s.start,s.end)?.getBoundingClientRect();if(!c||t<c.left-1||t>c.right+1||n<c.top-1||n>c.bottom+1)return null;let l=i.closest(`[data-hunk-id]`)?.getAttribute(`data-hunk-id`);if(!l)return null;let u=r.get(l);if(!u)return null;let d=i.dataset.side===`base`?`base`:`head`,f=Number(d===`base`?i.dataset.old:i.dataset.new);return{word:s.word,side:d,path:u,hunkId:l,line:Number.isFinite(f)&&f>0?f:null,cell:i,start:s.start,end:s.end}}function Z(e,t){let n=globalThis.CSS?.highlights;if(!n||typeof Highlight>`u`)return;let r=RegExp(`(?<![\\w$])${e.replace(/[$\\]/g,`\\$&`)}(?![\\w$])`,`g`),i=new Highlight,a=window.innerHeight,o=t===`base`?`td[data-old]`:`td[data-new]`;for(let e of document.querySelectorAll(`.hunk-lines`)){let t=e.getBoundingClientRect();if(!(t.bottom<0||t.top>a))for(let t of e.querySelectorAll(o)){let e=t.textContent;if(e)for(let n of e.matchAll(r)){let e=Yu(t,n.index,n.index+n[0].length);e&&i.add(e)}}}n.set(zu,i)}function Q(){globalThis.CSS?.highlights?.delete(zu)}var Zu=12e3;function Qu({status:e,onShown:t,onAcknowledge:n}){let r=(0,x.useRef)(e.notice===`pending`),i=(0,x.useRef)(!1),a=e.enabled&&e.notice!==`acknowledged`;(0,x.useEffect)(()=>{a&&r.current&&!i.current&&(i.current=!0,t())},[a,t]);let[o,s]=(0,x.useState)(!1),c=(0,x.useRef)(Zu),[l,u]=(0,x.useState)(Zu);return(0,x.useEffect)(()=>{if(!a||o)return;let e,t,r=0,i=()=>Math.max(0,c.current-(Date.now()-r)),s=()=>{e===void 0&&(r=Date.now(),e=setTimeout(n,c.current),t=setInterval(()=>u(i()),250))},l=()=>{e!==void 0&&(clearTimeout(e),clearInterval(t),e=void 0,c.current=i(),u(c.current))},d=()=>document.visibilityState===`visible`?s():l();return d(),document.addEventListener(`visibilitychange`,d),()=>{l(),document.removeEventListener(`visibilitychange`,d)}},[a,o,n]),a?(0,S.jsxs)(`div`,{className:`telemetry-notice`,role:`status`,"aria-live":`polite`,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),onFocus:()=>s(!0),onBlur:()=>s(!1),children:[(0,S.jsx)(U,{name:`note`,size:`sm`}),(0,S.jsxs)(`p`,{className:`telemetry-notice-text`,children:[(0,S.jsx)(`strong`,{children:`Diffo sends anonymous usage data.`}),` Two small events per review, opened and finished: the version, your OS, the kind of review, which agent, and counts. Never code, paths, or comment text.`,` `,r.current?`Nothing has been sent yet, and nothing is during this review. `:``,`Turn it off any time under Settings → Privacy.`,` `,(0,S.jsx)(`a`,{href:e.docs,target:`_blank`,rel:`noreferrer`,children:`What is sent`})]}),(0,S.jsxs)(`span`,{className:`telemetry-notice-ok`,children:[(0,S.jsxs)(`svg`,{className:`telemetry-notice-ring`,viewBox:`0 0 40 40`,"aria-hidden":`true`,children:[(0,S.jsx)(`circle`,{className:`telemetry-notice-ring-track`,cx:`20`,cy:`20`,r:$u}),(0,S.jsx)(`circle`,{className:`telemetry-notice-ring-left`,cx:`20`,cy:`20`,r:$u,strokeDasharray:ed,strokeDashoffset:ed*(1-l/Zu)})]}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-sm telemetry-notice-ok-btn`,title:`dismiss; it closes on its own in a few seconds`,onClick:n,children:`OK`})]})]}):null}var $u=18,ed=2*Math.PI*$u;function td(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function nd({item:e,current:t,onOpen:n,onResolve:r,onReopen:i,onDelete:a}){let o=e.turn===`resolved`,s=at(e.thread),c=o?i:r,l=e.turn===`yours`||e.turn===`unanswered`,u=e.anchor??`the whole changeset`,d=e.outdated?`, outdated on GitHub: the line left the diff`:e.gone?`, this file left the changeset`:``;return(0,S.jsxs)(`div`,{className:`crow${l?` crow-hot`:``}${o?` crow-done`:``}`,"aria-current":t?`true`:void 0,"data-thread":e.thread.id,children:[s?(0,S.jsx)(`button`,{type:`button`,className:`crow-mark`,"data-tip":`Discard draft: drops it; nothing was posted`,"aria-label":`Discard draft`,disabled:!a,onClick:()=>a&&void a(e.thread.id),children:(0,S.jsx)(U,{name:`trash`,size:`sm`})}):(0,S.jsx)(`button`,{type:`button`,className:`crow-mark`,"aria-pressed":o,"data-tip":o?`Reopen: moves back to its turn`:`Resolve: moves to Settled`,"aria-label":o?`Reopen thread`:`Resolve thread`,disabled:!c,onClick:()=>c&&void c(e.thread.id),children:(0,S.jsx)(U,{name:`check`,size:`sm`})}),(0,S.jsxs)(`button`,{type:`button`,className:`crow-pick`,title:`${u}${d}`,onClick:()=>n?.(e),children:[(0,S.jsx)(`span`,{className:`crow-q`,children:e.question}),(0,S.jsxs)(`span`,{className:`crow-sub`,children:[e.turn===`note`&&it(e.thread)&&(0,S.jsx)(`span`,{className:`crow-pill`,children:`Draft`}),rt(e.thread)!==null&&(0,S.jsxs)(`span`,{className:`crow-pill crow-pill-pr`,title:`your agent drafted a review comment for the author`,children:[(0,S.jsx)(U,{name:`globe`,size:`sm`}),` suggests`]}),e.thread.intent&&e.turn!==`proposed`&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`crow-kind crow-kind-${e.thread.intent}`,children:xc[e.thread.intent]}),(0,S.jsx)(`span`,{className:`crow-sep`,children:`·`})]}),(0,S.jsx)(`span`,{className:`crow-where${e.gone?` crow-where-gone`:``}`,children:td(u)}),it(e.thread)?id(e)&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`crow-sep`,children:`·`}),(0,S.jsx)(`span`,{className:`crow-state`,children:id(e)})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`crow-sep`,children:`·`}),(0,S.jsx)(`span`,{className:`crow-state crow-state-${e.turn}`,children:rd(e)})]})]})]}),(0,S.jsx)(`span`,{className:`crow-when`,children:va(e.updatedAt)}),a&&!s&&(0,S.jsx)(`button`,{type:`button`,className:`row-act row-act-danger crow-del`,"data-tip":`Delete thread`,"aria-label":`Delete thread`,onClick:()=>void a(e.thread.id),children:(0,S.jsx)(U,{name:`trash`,size:`sm`})})]})}function rd(e){switch(e.turn){case`yours`:return e.outcome===`changed`?`changed the code, no reply`:e.answer??`answered`;case`unanswered`:return`no answer, the agent moved on`;case`proposed`:return`from the agent: reply or resolve`;case`agent`:return e.working?`agent is on it`:e.queued===void 0?`waiting on the agent`:`queued, ${Tc(e.queued)}`;case`note`:return`draft, not sent`;case`posted`:return e.answer??`on GitHub`;case`resolved`:return e.answer??`resolved`}}function id(e){let t=e.thread;if(e.turn===`note`)return null;if(ot(t).length>0)return`reply pending`;if(t.queued?.resolve)return`resolves when you submit`;if(t.queued?.unresolve)return`reopens when you submit`;let n=ad(t);return e.turn===`resolved`?n?`${n} · resolved`:`resolved`:n??`on GitHub`}function ad(e){for(let t=e.messages.length-1;t>=0;t--){let n=e.messages[t];if(n.author===`github`&&n.github)return n.github.user.login}return null}var od=new Set([`settled`]),sd={github:{icon:`globe`,label:`GitHub`,empty:`No PR comments yet`},agent:{icon:`lock`,label:`Private`,empty:`Nothing asked of the agent yet`}},cd=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function ld(e,t){let n=e=>t.filter(e).length;if(e===`github`){let e=n(e=>e.turn===`note`);return e>0?{text:cd(e,`draft`),hot:!1}:null}let r=n(e=>e.turn===`yours`||e.turn===`unanswered`);if(r>0)return{text:`${r} your turn`,hot:!0};let i=n(e=>e.turn===`proposed`);if(i>0)return{text:`${i} from the agent`,hot:!1};let a=n(e=>e.turn===`agent`);return a>0?{text:`${a} waiting`,hot:!1}:null}function ud({side:e,group:t,selectedThreadId:n,row:r}){let[i,a]=(0,x.useState)(!1),[o,s]=(0,x.useState)(`auto`),[c,l]=(0,x.useState)(`auto`),[u,d]=(0,x.useState)(n),f=fs()?.viewer.login??null,p=sd[e],m=ld(e,t),h=t.filter(e=>e.turn!==`resolved`),g=t.filter(e=>e.turn===`resolved`),_=e===`github`?h.filter(e=>Cs(e.thread,f)):h,v=h.filter(e=>!_.includes(e)),y=e=>e.thread.id===n;u!==n&&(d(n),o===`closed`&&v.some(y)&&s(`auto`),c===`closed`&&g.some(y)&&l(`auto`));let b=(e,t)=>e===`open`||e===`auto`&&t,C=b(o,v.some(y)),w=C?[..._,...v]:_,T=b(c,g.some(y));return(0,S.jsxs)(`section`,{className:`side side-${e}`,"aria-label":`${p.label} threads`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`side-head`,"aria-expanded":!i,onClick:()=>a(!i),children:[(0,S.jsx)(`span`,{className:`chevron${i?` chevron-shut`:``}`,children:(0,S.jsx)(U,{name:`chev`,size:`sm`})}),(0,S.jsx)(U,{name:p.icon,size:`sm`}),(0,S.jsx)(`span`,{className:`side-name`,children:p.label}),` `,(0,S.jsx)(`span`,{className:`side-n`,children:t.length}),m&&(0,S.jsxs)(S.Fragment,{children:[` `,(0,S.jsx)(`span`,{className:`side-badge${m.hot?` side-badge-hot`:``}`,children:m.text})]})]}),!i&&t.length===0&&(0,S.jsx)(`div`,{className:`side-empty`,children:p.empty}),!i&&w.map(r),!i&&(v.length>0||g.length>0)&&(0,S.jsxs)(`div`,{className:`side-tail`,children:[v.length>0&&(0,S.jsx)(`button`,{type:`button`,className:`side-more`,"aria-expanded":C,title:C?`back to the threads you are part of`:`threads on this pull request you are not part of, bots included`,onClick:()=>s(C?`closed`:`open`),children:C?`Only mine`:`${v.length} from others`}),g.length>0&&(0,S.jsxs)(`button`,{type:`button`,className:`side-more`,"aria-expanded":T,onClick:()=>l(T?`closed`:`open`),children:[g.length,` `,e===`github`?`resolved`:`settled`]})]}),!i&&T&&g.map(r)]})}function dd({items:e,pastItems:t=[],selectedThreadId:n,totalThreads:r,onOpen:i,onResolve:a,onReopen:o,onDelete:s,onClearAll:c,pr:l=!1}){let[u,d]=(0,x.useState)(od),f=(0,x.useMemo)(()=>[...e,...t.map(e=>({...e,gone:!0}))],[e,t]),p=(0,x.useMemo)(()=>Os(f),[f]),m=(0,x.useMemo)(()=>l?ws(f):null,[l,f]),h=(e,t)=>e===`yours`&&a?{icon:`check`,danger:!1,label:`Resolve all ${t.length}`,run:()=>t.forEach(e=>void a(e.thread.id))}:e===`settled`&&s?{icon:`trash`,danger:!0,label:`Delete all ${t.length} settled`,run:()=>t.forEach(e=>void s(e.thread.id))}:null,g=c&&(0,S.jsxs)(`button`,{type:`button`,className:`clist-clear`,onClick:c,children:[`Clear all threads`,r!==void 0&&r>0?` (${r})`:``,`…`]}),_=e=>(0,S.jsx)(nd,{item:e,current:n===e.thread.id,onOpen:i,onResolve:a,onReopen:o,onDelete:s},e.thread.id);if(m)return(0,S.jsxs)(`div`,{className:`clist clist-pr`,children:[[`github`,`agent`].map(e=>(0,S.jsx)(ud,{side:e,group:m[e],selectedThreadId:n,row:_},e)),f.length>0&&g]});if(p.size===0)return(0,S.jsx)(`div`,{className:`clist`,children:(0,S.jsxs)(`div`,{className:`rail-empty`,children:[`No threads yet.`,(0,S.jsx)(`br`,{}),`Comment on any diff line to start one.`]})});let v=p.size===1&&p.has(`settled`);return(0,S.jsxs)(`div`,{className:`clist`,children:[v&&(0,S.jsxs)(`div`,{className:`clist-quiet`,children:[`Nothing needs you.`,(0,S.jsx)(`br`,{}),(0,S.jsxs)(`span`,{className:`clist-quiet-n`,children:[p.get(`settled`).length,` settled.`]})]}),[...p].map(([e,t])=>{let n=u.has(e),r=h(e,t);return(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`div`,{className:`sec-row${r?` sec-row-hasact`:``}`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`sec-head sec-head-fold${e===`yours`?` sec-head-hot`:``}`,"aria-expanded":!n,onClick:()=>d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),children:[(0,S.jsx)(`span`,{className:`chevron${n?` chevron-shut`:``}`,children:(0,S.jsx)(U,{name:`chev`,size:`sm`})}),vs[e],` `,(0,S.jsx)(`span`,{className:`sec-n`,children:t.length})]}),r&&(0,S.jsx)(`button`,{type:`button`,className:`row-act sec-act${r.danger?` row-act-danger`:``}`,"data-tip":r.label,"aria-label":r.label,onClick:r.run,children:(0,S.jsx)(U,{name:r.icon,size:`sm`})})]}),!n&&t.map(_)]},e)}),g]})}var fd=`diffo:ui:critter`;function pd(){try{return localStorage.getItem(fd)!==`off`}catch{return!0}}function md(e){try{e?localStorage.removeItem(fd):localStorage.setItem(fd,`off`)}catch{}}async function hd(){try{let e=await fetch(`/api/settings`);if(!e.ok)return null;let t=await e.json();return t?.critter===`on`||t?.critter!==`off`&&null}catch{return null}}function gd(e){e?document.documentElement.removeAttribute(`data-motion`):document.documentElement.setAttribute(`data-motion`,`off`)}function _d(){let[e,t]=(0,x.useState)(pd);return(0,x.useEffect)(()=>{gd(e)},[e]),(0,x.useEffect)(()=>{let e=!1;return hd().then(n=>{e||n===null||n===pd()||(md(n),t(n))}),()=>{e=!0}},[]),[e,(0,x.useCallback)(e=>{t(e),md(e),fetch(`/api/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({critter:e?`on`:`off`})}).catch(()=>{})},[])]}function vd(e,t){return e===`j`?`next-hunk`:e===`]`?`next-layer`:e===`[`?`prev-layer`:e===`.`?`next-decision`:e===`k`?`prev-hunk`:e===`J`||t&&e===`j`?`next-file`:e===`K`||t&&e===`k`?`prev-file`:e===`v`?`toggle-viewed`:e===`u`?`toggle-view-mode`:e===`b`?`toggle-nav`:e===`/`?`focus-search`:e===`c`?`comment`:e===`n`?`next-unreviewed`:e===`o`?`toggle-fold`:e===`h`?`hide-reviewed`:e===`?`?`shortcuts`:null}function yd(e){return e instanceof HTMLElement?e.tagName===`INPUT`||e.tagName===`TEXTAREA`||e.isContentEditable:!1}var bd={changedHunkIds:new Set,changedFiles:[],changed:new Set},xd=new Set,Sd=e=>e.hunks.length>0;function Cd(e,t,n=xd){if(!e||!t)return bd;let r=new Set(t.hunkIds),i=new Set,a=[];for(let t of e.files){if(!Sd(t))continue;let e=t.hunks.filter(e=>!r.has(e.id)&&!n.has(e.id));if(e.length!==0){for(let t of e)i.add(t.id);a.push(t.path)}}return{changedHunkIds:i,changedFiles:a,changed:new Set(a)}}function wd(){let e=w(),t=H({queryKey:[`telemetry`],queryFn:async()=>{try{let e=await fetch(`/api/telemetry`);return e.ok?await e.json():null}catch{return null}},staleTime:1/0}),n=async t=>{try{let n=await fetch(`/api/telemetry`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});n.ok&&e.setQueryData([`telemetry`],await n.json())}catch{}};return{status:t.data??null,markShown:()=>void n({notice:`shown`}),acknowledge:()=>void n({notice:`acknowledged`}),setEnabled:e=>void n({enabled:e})}}var Td=`diffo:ui:theme`;function Ed(e){return e===`system`||e===`light`||e===`dark`?e:null}function Dd(){let e=localStorage.getItem(Td);return e===`light`||e===`dark`?e:`system`}function Od(e){e===`system`?localStorage.removeItem(Td):localStorage.setItem(Td,e)}function kd(e){e===`system`?document.documentElement.removeAttribute(`data-theme`):document.documentElement.setAttribute(`data-theme`,e)}async function Ad(){try{let e=await fetch(`/api/settings`);return e.ok?Ed((await e.json())?.theme):null}catch{return null}}function jd(e){fetch(`/api/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({theme:e})}).catch(()=>{})}function Md(){let[e,t]=(0,x.useState)(Dd);return(0,x.useEffect)(()=>{let e=!1;return Ad().then(n=>{e||n===null||n===Dd()||(Od(n),kd(n),t(n))}),()=>{e=!0}},[]),[e,(0,x.useCallback)(e=>{t(e),kd(e),Od(e),jd(e)},[])]}var Nd=(e,t)=>`${e}:${t}`;function Pd(e){return e.flatMap(e=>e.messages.filter(e=>e.author===`agent`).map(t=>Nd(e.id,t.id)))}function Fd(e){let t=e.anchor;return t.kind===`changeset`?null:t.kind===`file`?t.path:t.kind===`layer`?`layer “${t.title}”`:`${t.path}:${t.line}`}function Id(e,t){let n=[];for(let r of e){let e=[...r.messages].reverse().find(e=>e.author===`agent`);if(!e||t.has(Nd(r.id,e.id)))continue;let i=lt(r);n.push({key:Nd(r.id,e.id),kind:i?r.anchor.kind===`changeset`?`guide`:`thread`:`answer`,threadId:r.id,anchor:Fd(r),preview:e.text.split(`
93
+ `,1)[0].trim()})}return n}function Ld(e,t){return e>0?`(${e}) ${t}`:t}function Rd(e,t,n=!1){return e?n?`dev · ${e}`:e:t}var zd=8e3;function Bd(e,t){let n=0;return e.map(e=>e.kind===`guide`?e:{...e,expiresAt:t+350*n++})}function Vd(e,t){let n=-1/0;for(let t of e)t.expiresAt!==null&&t.expiresAt>n&&(n=t.expiresAt);return Math.max(t+zd,n+350)}function Hd(e){let t=document;if(typeof t.startViewTransition!=`function`){e();return}let n=t.startViewTransition(()=>(0,kt.flushSync)(e));n.ready.catch(()=>{}),n.finished.catch(()=>{})}function Ud({threads:e,title:t,onOpenThread:n}){let[r,i]=(0,x.useState)([]),a=(0,x.useRef)(null),o=(0,x.useRef)(document.title),s=(0,x.useRef)(Rt()),c=(0,x.useRef)(t),l=(0,x.useRef)(0),u=(0,x.useRef)(n);u.current=n;let d=(0,x.useCallback)(()=>{document.title=Ld(l.current,Rd(c.current,o.current,s.current))},[]);(0,x.useEffect)(()=>{c.current=t,d()},[t,d]),(0,x.useEffect)(()=>{if(!e)return;if(a.current===null){a.current=new Set(Pd(e));return}let t=Id(e,a.current);for(let t of Pd(e))a.current.add(t);if(t.length===0)return;if(document.hasFocus()){let e=Date.now(),n=t.map(e=>({...e,expiresAt:null}));Hd(()=>i(t=>[...t,...Bd(n,Vd(t,e))]));return}l.current+=t.length,d();let n=t.map(e=>({...e,expiresAt:null}));Hd(()=>i(e=>[...e.map(e=>e.expiresAt===null?e:{...e,expiresAt:null}),...n]))},[e,d]),(0,x.useEffect)(()=>{let e=()=>{l.current=0,d();let e=Date.now()+zd;i(t=>Bd(t,e))};return window.addEventListener(`focus`,e),()=>{window.removeEventListener(`focus`,e),l.current=0,d()}},[d]),(0,x.useEffect)(()=>{let e=1/0;for(let t of r)t.expiresAt!==null&&t.expiresAt<e&&(e=t.expiresAt);if(e===1/0)return;let t=setTimeout(()=>{let e=Date.now();Hd(()=>i(t=>t.filter(t=>t.expiresAt===null||t.expiresAt>e)))},Math.max(0,e-Date.now()));return()=>clearTimeout(t)},[r]);let f=(0,x.useCallback)(()=>Hd(()=>i([])),[]),p=(0,x.useCallback)(e=>{Hd(()=>i(t=>t.filter(t=>t.key!==e.key)))},[]);return{notices:r,open:(0,x.useCallback)(e=>{Hd(()=>i(t=>t.filter(t=>t.key!==e.key))),u.current(e.threadId)},[]),dismiss:p,clear:f}}function Wd(e){return`diffo:viewed:${e.repo.path}:${Kd(e)}`}function Gd(e){return`diffo:viewed:${e.repo.name}:${Kd(e)}`}function Kd(e){return e.spec.kind===`working-tree`?`working-tree`:`branch:${e.spec.base}`}function qd(e){try{let t=localStorage.getItem(e);if(!t)return new Set;let n=JSON.parse(t);return Array.isArray(n)?new Set(n.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}function Jd(e,t){try{localStorage.setItem(e,JSON.stringify([...t]))}catch{}}function Yd(e){let t=e?Wd(e):null,n=e?Gd(e):null,[r,i]=(0,x.useState)(new Set),[a,o]=(0,x.useState)(!1);(0,x.useEffect)(()=>{if(!t)return;let e=qd(t);if(e.size===0&&n!==null&&n!==t){let e=qd(n);if(e.size>0){Jd(t,e),i(e),o(!0);return}}i(e),o(!0)},[t,n]);let s=(0,x.useCallback)(n=>{let r=e?.files.find(e=>e.path===n);r&&i(e=>{let n=new Set(e),i=uo(r),a=i.every(e=>n.has(e));for(let e of i)a?n.delete(e):n.add(e);return t&&Jd(t,n),n})},[e,t]),c=(0,x.useCallback)((n,r)=>{let a=new Set(n);i(n=>{let i=new Set(n);for(let t of e?.files??[])if(a.has(t.path))for(let e of uo(t))r?i.add(e):i.delete(e);return t&&Jd(t,i),i})},[e,t]);return{viewed:r,loaded:a,toggleFile:s,markFiles:(0,x.useCallback)(e=>c(e,!0),[c]),clearFiles:(0,x.useCallback)(e=>c(e,!1),[c]),progress:(0,x.useMemo)(()=>{let t=0,n=0;for(let i of e?.files??[])for(let e of i.hunks)t++,r.has(e.id)&&n++;return{viewed:n,total:t}},[e,r]),fileProgress:(0,x.useMemo)(()=>{let t=0,n=0;for(let i of e?.files??[])t++,po(i,r)&&n++;return{viewed:n,total:t}},[e,r])}}var Xd=new Ue,Zd=264,Qd=800,$d=200,ef=520,tf=e=>Math.min(ef,Math.max($d,e)),nf=12,rf=`overview`,af=16,of=new Set,sf=new Map;function cf(e){e.removeAttribute(`data-found`),e.offsetWidth,e.setAttribute(`data-found`,``);let t=()=>e.removeAttribute(`data-found`);e.addEventListener(`animationend`,t,{once:!0}),setTimeout(t,2e3)}var lf=[];function uf(){let e=w(),[t,n]=(0,x.useState)(`waiting`),[r,i]=(0,x.useState)(null),[a,o]=(0,x.useState)(`no-agent`),[s,c]=(0,x.useState)(null),[l,u]=(0,x.useState)(of),[d,f]=(0,x.useState)(sf),[p,m]=(0,x.useState)(of);return(0,x.useEffect)(()=>{let t=new EventSource(`/api/events`);return t.addEventListener(`changeset`,()=>{e.invalidateQueries({queryKey:[`changeset`]})}),t.addEventListener(`review`,()=>{e.invalidateQueries({queryKey:[`review`]})}),t.addEventListener(`presence`,e=>{try{let t=JSON.parse(e.data),{state:r}=t;(r===`waiting`||r===`listening`||r===`working`)&&(n(r),i(t.layers===`queued`||t.layers===`outlining`?t.layers:null),t.reason&&o(t.reason),c(typeof t.since==`number`?t.since:null),u(r===`working`&&Array.isArray(t.workingOn)?new Set(t.workingOn.filter(e=>typeof e==`string`)):of),f(r!==`waiting`&&Array.isArray(t.queued)?new Map(t.queued.filter(e=>typeof e==`string`).map((e,t)=>[e,t+1])):sf),m(r!==`waiting`&&Array.isArray(t.answered)?new Set(t.answered.filter(e=>typeof e==`string`)):of))}catch{}}),t.onopen=()=>{e.invalidateQueries({queryKey:[`review`]}),e.invalidateQueries({queryKey:[`changeset`]})},t.onerror=()=>{n(`waiting`),o(`disconnected`),c(null),u(of),f(sf),m(of),i(null)},()=>t.close()},[e]),{presence:t,reason:a,since:s,workingOn:l,queuedOn:d,answeredOn:p,layersRequest:r}}function df(e,t,n){let[r,i]=(0,x.useState)(null),a=(0,x.useRef)(of);return(0,x.useEffect)(()=>{let r=a.current;if(a.current=t,n!==`working`||t.size===0){i(null);return}let o=[...t].filter(e=>!r.has(e));if(o.length===0)return;let s=e.find(e=>e.thread.id===o[o.length-1]);s&&i(Es(s.anchor))},[e,t,n]),r}function ff(){let e=w();return(0,x.useMemo)(()=>{let t=()=>e.invalidateQueries({queryKey:[`review`]});return{create:async(e,n,r,i)=>{let a=await St.createThread(e,n,r,i);return await t(),a},reply:(e,n,r)=>St.reply(e,n,r).then(t),edit:(e,n,r,i)=>St.editMessage(e,n,r,i).then(t),send:async e=>{let{prompt:n,delivered:r,presence:i}=await St.send(e);if(r||i!==`waiting`)return await t(),{delivered:!0};let a=await Ct(n);return await t(),{delivered:!1,copied:a,prompt:n}},resolve:e=>St.setState(e,`resolved`).then(t),reopen:e=>St.setState(e,`open`).then(t),remove:e=>St.remove(e).then(t),dismissPrComment:(e,n)=>St.dismissPrComment(e,n).then(t)}},[e])}function pf(){let{data:e,isLoading:t,error:n}=mt(),{presence:r,reason:i,since:a,workingOn:o,queuedOn:s,answeredOn:c,layersRequest:l}=uf(),{viewed:u,loaded:d,toggleFile:f,markFiles:p,clearFiles:m,progress:h,fileProgress:g}=Yd(e),[_,v]=(0,x.useState)(`unified`),[y,b]=(0,x.useState)(null),[C,w]=(0,x.useState)(null),[T,E]=(0,x.useState)(new Set),[D,O]=(0,x.useState)(()=>{let e=localStorage.getItem(`diffo:ui:navHidden`);return e===null?window.innerWidth<Qd:e===`1`}),[k,A]=(0,x.useState)(()=>{let e=Number(localStorage.getItem(`diffo:ui:railWidth`));return e>0?tf(e):Zd}),[j,M]=(0,x.useState)(!1),N=(0,x.useRef)(null),P=(0,x.useRef)(k);P.current=j?P.current:k;let F=(0,x.useRef)(null);(0,x.useEffect)(()=>()=>F.current?.(),[]);let{data:I}=ht(),ee=ff(),[te,ne]=(0,x.useState)(null),[L,re]=(0,x.useState)(null),[ie,ae]=(0,x.useState)(!1),[oe,se]=(0,x.useState)(!1),[ce,le]=(0,x.useState)(!1),[ue,de]=(0,x.useState)(!1),[R,z]=(0,x.useState)(!1),[B,fe]=Md(),[pe,me]=_d(),he=wd(),[ge,_e]=(0,x.useState)(!1),[ve,ye]=(0,x.useState)(`files`),[be,xe]=(0,x.useState)(0),Se=e?.pr??null,Ce=r!==`waiting`,[we,Te]=(0,x.useState)(!1),Ee=(0,x.useMemo)(()=>Cd(e,I?.lastFinish,u),[e,I,u]),De=(0,x.useMemo)(()=>$o(e?.files??[]),[e]),V=Jo(De,(0,x.useCallback)(e=>po(e,u),[u]),{on:we,changed:Ee.changed,set:Te}),Oe=(0,x.useMemo)(()=>vo(I?.layers,De),[I?.layers,De]),ke=Oe.length>0,Ae=(0,x.useMemo)(()=>Co(Oe),[Oe]),je=(0,x.useMemo)(()=>V.hideTests?yo(Oe,e=>Ho(e.path)&&!V.pinned.has(e.path)):Oe,[Oe,V.hideTests,V.pinned]),[Me,Ne]=(0,x.useState)(null),[Pe,Fe]=(0,x.useState)(null);(0,x.useEffect)(()=>Fe(null),[Me]);let Ie=(0,x.useMemo)(()=>xo(I?.threads??[]),[I?.threads]),Le=(0,x.useMemo)(()=>Se?So(I?.threads??[]):void 0,[Se,I?.threads]),Re=Ie!==void 0||Le!==void 0,ze=ke&&Me===rf&&Re,Be=Oe.findIndex(e=>bo(e)===Me),Ve=(0,x.useMemo)(()=>Oe.every(e=>e.files.every(e=>!po(e.file,u))),[Oe,u]),He=ke?ze?-1:Be===-1?Oo(je,u):Be:-1,Ue=ke&&He>=0?je[He]:void 0,We=ke&&He>=0?Oe[He]:void 0,Ge=ke&&ve===`layers`,Ke=Ge?Ue:void 0;(0,x.useEffect)(()=>{ke&&d&&Be===-1&&!ze&&Ne(Re&&Ve&&Me===null?rf:bo(Oe[He]))},[ke,d,Be,ze,Oe,He,Re,Ve,Me]);let qe=(0,x.useMemo)(()=>Ge&&ze?[]:Ke?Ke.files.map(e=>e.file):V.files,[Ge,ze,Ke,V.files]),Je=(0,x.useCallback)(e=>e.files.length===0,[]),[Ye,Xe]=(0,x.useState)(nf),Ze=(0,x.useCallback)(()=>Xe(e=>e+nf),[]),Qe=(0,x.useCallback)(e=>{let t=Oe[e];t&&(Ne(bo(t)),b(null),w(null),Xe(nf),requestAnimationFrame(()=>{document.querySelector(`.reading-pane`)?.scrollTo({top:0})}))},[Oe]),$e=(0,x.useCallback)(()=>{Ne(rf),b(null),w(null),requestAnimationFrame(()=>{document.querySelector(`.reading-pane`)?.scrollTo({top:0})})},[]),et=(0,x.useCallback)(e=>{if(!Ge||We?.files.some(t=>t.file.path===e))return;let t=Ae.get(e);t&&Qe(Oe.indexOf(t))},[Ge,We,Ae,Oe,Qe]),tt=Ke?.kind===`mechanical`?bo(Ke):null,H=(0,x.useRef)(Ke);H.current=Ke;let nt=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(tt===null)return;let e=nt.current,t=(H.current?.files??[]).map(e=>e.file.path).filter(t=>t!==e);E(e=>new Set([...e,...t]))},[tt]),(0,x.useEffect)(()=>{ke&&ye(`layers`)},[ke]);let rt=(0,x.useCallback)(()=>{St.requestLayers().catch(()=>{})},[]),it=(0,x.useCallback)(e=>{V.pin(e);let t=Ge?We?.files.some(t=>t.file.path===e)?We:Ae.get(e):void 0,n=t?t.files.findIndex(t=>t.file.path===e):De.findIndex(t=>t.path===e);n>=0&&Xe(e=>Math.max(e,n+1))},[De,V.pin,Ge,We,Ae]),ot=(0,x.useMemo)(()=>qe.slice(0,Ye),[qe,Ye]),{active:st,past:ct}=(0,x.useMemo)(()=>{let t=ft(e?.files??[],I?.threads??[],I?.layers),n=t.active.filter(e=>e.github?.outdated===!0);return n.length===0?t:{active:t.active.filter(e=>e.github?.outdated!==!0),past:[...t.past,...n]}},[e,I]),ut=(0,x.useMemo)(()=>Pl(e?.files??[],st),[e,st]),dt=(0,x.useMemo)(()=>Ts(st,o,s),[st,o,s]),pt=(0,x.useMemo)(()=>({stillTo:dt.filter(e=>e.turn===`agent`).sort((e,t)=>(e.working===!0?0:e.queued??2**53-1)-(t.working===!0?0:t.queued??2**53-1)),back:dt.filter(e=>c.has(e.thread.id))}),[dt,c]),gt=(0,x.useMemo)(()=>({segments:[...pt.back.map(()=>`done`),...pt.stillTo.map(e=>e.working===!0?`now`:`wait`)],done:pt.back.length}),[pt]),_t=df(dt,c,r),vt=r===`working`?Ds(pt.stillTo,_t)??(l===`outlining`?`outlining layers`:null):null,[yt,bt]=(0,x.useState)(!1);(0,x.useEffect)(()=>{yt&&pt.stillTo.length===0&&pt.back.length===0&&bt(!1)},[yt,pt]),(0,x.useEffect)(()=>{we&&Ee.changed.size===0&&Te(!1)},[we,Ee]);let xt=(0,x.useMemo)(()=>Ts(ct),[ct]),Ct=(0,x.useMemo)(()=>js(dt),[dt]),wt=(0,x.useMemo)(()=>Il(e?.files??[],ut),[e,ut]),Et=ks(dt)+ks(xt),Dt=As(dt)+As(xt),kt=dt.length+xt.length-Dt,[At,Mt]=(0,x.useState)(0),[Nt,Ft]=(0,x.useState)(0),[It,Lt]=(0,x.useState)(null),[Rt,zt]=(0,x.useState)(null),Bt=(0,x.useMemo)(()=>({partition:ut,past:ct,actions:ee,agentConnected:Ce,workingOn:o,queuedOn:s,composeHunkId:te,onComposeHandled:()=>ne(null),composeFilePath:L,onComposeFileHandled:()=>re(null),changesetComposerOpen:ie,onOpenChangesetComposer:()=>ae(!0),onCloseChangesetComposer:()=>ae(!1),revealNotesTick:At,revealPastTick:Nt,revealThreadId:It}),[ut,ct,ee,Ce,o,s,te,L,ie,At,Nt,It]),W=(0,x.useMemo)(()=>{let e=0;for(let t of st)ms(t)&&e++;return e},[st]),Vt=(0,x.useMemo)(()=>st.filter(at).length+ct.filter(at).length,[st,ct]),[Ht,Ut]=(0,x.useState)(new Set),Wt=(0,x.useMemo)(()=>{let e=new Set;for(let t of st)lt(t)||(t.anchor.kind===`hunk`||t.anchor.kind===`file`)&&e.add(t.anchor.path);return e},[st]),Gt=(0,x.useMemo)(()=>{let e=De.filter(e=>!po(e,u)),t=e.filter(e=>Ht.has(e.path)).map(e=>e.path),n=new Set(t),r=new Set(V.scope.excludedPaths),i=e.filter(e=>!n.has(e.path));return{viewedHunks:h.viewed,totalHunks:h.total,viewedFiles:g.viewed,totalFiles:g.total,changedFiles:t,commentedUnread:i.filter(e=>Wt.has(e.path)).map(e=>e.path),filteredOut:i.filter(e=>!Wt.has(e.path)&&r.has(e.path)).map(e=>e.path),skippedFiles:i.filter(e=>!Wt.has(e.path)&&!r.has(e.path)).map(e=>e.path)}},[De,h,g,u,Ht,Wt,V.scope.excludedPaths]),Kt=(0,x.useCallback)(async()=>{await St.clear(),await Xd.invalidateQueries({queryKey:[`review`]})},[]),qt=(0,x.useCallback)(()=>{Xd.setQueryData([`review`],e=>e&&{...e,landed:void 0}),St.dismissLanded().then(()=>Xd.invalidateQueries({queryKey:[`review`]}))},[]),Jt=(0,x.useMemo)(()=>{if(I?.landed)return{sha:I.landed.sha,subject:I.landed.subject,threads:I.threads.length,onClear:Kt,onDismiss:qt}},[I,Kt,qt]),Yt=(0,x.useMemo)(()=>{let e=e=>e.turn===`yours`||e.turn===`unanswered`;return[...dt.filter(e),...xt.filter(e).map(e=>({...e,gone:!0}))]},[dt,xt]),Xt=(0,x.useCallback)(async()=>{await Xd.invalidateQueries({queryKey:[`review`]}),await Xd.invalidateQueries({queryKey:[`finish-preview`]})},[]),Zt=(0,x.useCallback)(e=>St.setState(e,`resolved`).then(Xt),[Xt]),Qt=(0,x.useCallback)(e=>St.setState(e,`open`).then(Xt),[Xt]),$t=(0,x.useCallback)(async(e,t)=>{let n={...Gt,...t&&t.note.trim()!==``?{note:t.note.trim()}:{}},{prompt:r,delivered:i,presence:a,public:o}=await St.finish(n,e,t?.event);await Xd.invalidateQueries({queryKey:[`review`]}),await Xd.invalidateQueries({queryKey:[`changeset`]}),await Xd.invalidateQueries({queryKey:[`finish-preview`]});let s=i||a!==`waiting`;return e&&s&&W>0&&!o?.failed&&bt(!0),{prompt:r,delivered:s,...o?{public:o}:{}}},[Gt,W]),en=(0,x.useCallback)(e=>{let t=tf(e);P.current=t,A(t),localStorage.setItem(`diffo:ui:railWidth`,String(t))},[]),tn=(0,x.useCallback)(e=>{if(e.button!==0)return;e.preventDefault();let t=e.clientX,n=P.current,r=n,i=e=>{r=tf(n+e.clientX-t),P.current=r,N.current?.style.setProperty(`--rail-w`,`${r}px`)},a=()=>{F.current?.(),F.current=null,M(!1),en(r)};F.current=()=>{document.removeEventListener(`pointermove`,i),document.removeEventListener(`pointerup`,a),document.removeEventListener(`pointercancel`,a),document.body.style.userSelect=``,document.body.style.cursor=``},document.addEventListener(`pointermove`,i),document.addEventListener(`pointerup`,a),document.addEventListener(`pointercancel`,a),document.body.style.userSelect=`none`,document.body.style.cursor=`col-resize`,M(!0)},[en]),nn=(0,x.useCallback)(()=>en(Zd),[en]),rn=(0,x.useRef)(localStorage.getItem(`diffo:ui:navHidden`)!==null),an=(0,x.useCallback)(()=>{rn.current=!0,O(e=>!e)},[]);(0,x.useEffect)(()=>{rn.current&&localStorage.setItem(`diffo:ui:navHidden`,D?`1`:`0`)},[D]);let on=(0,x.useRef)(!1);(0,x.useEffect)(()=>{if(on.current||!d||!e)return;on.current=!0;let t=e.files.filter(e=>po(e,u)).map(e=>e.path);t.length>0&&E(e=>new Set([...e,...t]))},[d,e,u]);let sn=(0,x.useCallback)(e=>{E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),cn=(0,x.useRef)(null),ln=(0,x.useCallback)(e=>{let t=document.querySelector(`.reading-pane`),n=document.getElementById(zo(e));if(!t||!n)return;let r=t.getBoundingClientRect().top,i=n.getBoundingClientRect(),a=i.top-r+t.scrollTop;i.bottom<=r?cn.current=t.scrollTop-(i.height+af):i.top<=r&&(cn.current=a)},[]);(0,x.useLayoutEffect)(()=>{let e=cn.current;if(e===null)return;cn.current=null;let t=document.querySelector(`.reading-pane`);t&&(t.scrollTop=Math.max(0,e))});let un=(0,x.useCallback)(t=>{let n=e?.files.find(e=>e.path===t);if(!n)return;let r=po(n,u);!r&&V.hideReviewed&&(ln(t),V.unpin(t)),f(t),E(e=>{let n=new Set(e);return r?n.delete(t):n.add(t),n})},[e,f,u,V.hideReviewed,V.unpin,ln]),dn=(0,x.useCallback)(e=>{let t=n=>{let r=document.getElementById(zo(e));r?Bo(r,cf):n>0&&requestAnimationFrame(()=>t(n-1))};requestAnimationFrame(()=>t(30))},[]),fn=(0,x.useCallback)(e=>{et(e),it(e),E(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n}),dn(e)},[it,et,dn]),pn=(0,x.useCallback)((t,n)=>{let r=e?.files.find(e=>e.path===t);if(!r)return;et(t),it(t),E(e=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n});let i=n===null?void 0:r.hunks.find(e=>e.lines.some(e=>e.kind!==`del`&&e.newNo===n));i?(b(i.id),w(null),requestAnimationFrame(()=>{let e=t=>{let n=document.querySelector(`[data-hunk-id="${i.id}"]`);n?Bo(n,cf):t>0&&requestAnimationFrame(()=>e(t-1))};e(30)})):dn(t)},[e,et,it,dn]),mn=(0,x.useCallback)(({path:t,side:n,line:r})=>{let i=e?.files.find(e=>e.path===t);if(!i)return;et(t),it(t),E(e=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n});let a=i.hunks.find(e=>e.lines.some(e=>(n===`base`?e.oldNo:e.newNo)===r));if(!a){dn(t);return}b(a.id),w(null);let o=`[data-hunk-id="${a.id}"] td[data-${n===`base`?`old`:`new`}="${r}"]`;requestAnimationFrame(()=>{let e=t=>{let n=document.querySelector(o)?.closest(`tr`);n?Bo(n,cf,`center`):t>0&&requestAnimationFrame(()=>e(t-1))};e(30)})},[e,et,it,dn]),hn=(0,x.useMemo)(()=>({paths:De.map(e=>e.path),onJump:pn}),[De,pn]),gn=(0,x.useMemo)(()=>({...Bt,links:hn}),[Bt,hn]),_n=(0,x.useCallback)(e=>{p(e);for(let t of e)V.unpin(t);E(t=>new Set([...t,...e]))},[p,V.unpin]),vn=(0,x.useCallback)(e=>{m(e),E(t=>{let n=new Set(t);for(let t of e)n.delete(t);return n})},[m]),yn=(0,x.useCallback)(()=>{let e=e=>!po(e,u),t;if(Ge){let n=Math.max(He,0),r=[...je.slice(n),...je.slice(0,n)];for(let n of r){let r=n.files.map(e=>e.file).find(e);if(r){t=r,n!==Ue&&Qe(je.indexOf(n));break}}}else t=De.find(e);t&&(it(t.path),E(e=>{if(!e.has(t.path))return e;let n=new Set(e);return n.delete(t.path),n}),b(t.hunks[0]?.id??null),w(t.hunks.length===0?t.path:null),dn(t.path))},[De,u,it,Ge,He,Ue,je,Qe,dn]),bn=(0,x.useCallback)(e=>{if(zt(e.threadId),e.gone)Ft(e=>e+1);else if(e.layerId!==void 0){ye(`layers`);let t=Oe.findIndex(t=>t.id===e.layerId);t!==-1&&bo(Oe[t])!==Me&&Qe(t)}else e.path?(nt.current=e.path,et(e.path),it(e.path),E(t=>{if(!t.has(e.path))return t;let n=new Set(t);return n.delete(e.path),n})):(Ge&&!ze&&(Re?$e():ye(`files`)),Lt(e.threadId),Mt(e=>e+1));let t=n=>{nt.current=null;let r=document.querySelector(`[data-thread-id="${e.threadId}"]`);if(r){Bo(r,cf);return}n>0&&requestAnimationFrame(()=>t(n-1))};requestAnimationFrame(()=>t(30))},[it,et,Oe,Me,Qe,Ge,ze,Re,$e]),xn=(0,x.useCallback)((e,t=!1)=>({threadId:e.thread.id,path:e.path,...e.thread.anchor.kind===`layer`?{layerId:e.thread.anchor.layerId}:{},...t?{gone:t}:{}}),[]),Sn=(0,x.useCallback)(e=>{let t=dt.find(t=>t.thread.id===e);if(t){bn(xn(t));return}let n=xt.find(t=>t.thread.id===e);n&&bn(xn(n,!0))},[dt,xt,bn,xn]),Cn=Ud({threads:I?.threads,title:I?.title,onOpenThread:Sn}),wn=(0,x.useRef)(null),Tn=(0,x.useMemo)(()=>{if(!e)return al;let t=wn.current;return t&&t.version===e.version?al:ol(t,e,qd(Wd(e)))},[e]);(0,x.useEffect)(()=>{e&&(wn.current=e)},[e]),(0,x.useEffect)(()=>{e&&Tn.changedViewedHunkIds.size!==0&&Ut(t=>{let n=new Set(t);for(let t of e.files)t.hunks.some(e=>Tn.changedViewedHunkIds.has(e.id))&&n.add(t.path);return n.size===t.size?t:n})},[e,Tn]);let G=(0,x.useMemo)(()=>qe.flatMap(e=>e.hunks.map(t=>({id:t.id,path:e.path}))),[qe]);(0,x.useEffect)(()=>{y&&!G.some(e=>e.id===y)&&b(null)},[G,y]);let En=G.find(e=>e.id===y)?.path??C,Dn=(0,x.useCallback)(e=>{if(G.length===0)return;let t=G.findIndex(e=>e.id===y),n=0;if(t!==-1){if(e===`next-hunk`)n=Math.min(t+1,G.length-1);else if(e===`prev-hunk`)n=Math.max(t-1,0);else if(e===`next-file`){let e=G[t].path,r=G.findIndex((n,r)=>r>t&&n.path!==e);n=r===-1?t:r}else{let e=G[t].path,r=[...G.slice(0,t)].reverse().find(t=>t.path!==e);n=r?G.findIndex(e=>e.path===r.path):t}}let{id:r,path:i}=G[n];b(r),w(null),it(i),requestAnimationFrame(()=>{document.querySelector(`[data-hunk-id="${r}"]`)?.scrollIntoView({behavior:`instant`,block:`center`})})},[G,y,it]);(0,x.useEffect)(()=>{let e=e=>{if(e.metaKey||e.ctrlKey||e.altKey||yd(e.target))return;let t=vd(e.key,e.shiftKey);if(t){if(e.preventDefault(),t===`toggle-viewed`)En&&un(En);else if(t===`comment`)y&&ne(y);else if(t===`toggle-view-mode`)v(e=>e===`unified`?`split`:`unified`);else if(t===`toggle-nav`)an();else if(t===`focus-search`)ye(`files`),O(!1),xe(e=>e+1);else if(t===`next-unreviewed`)yn();else if(t===`shortcuts`)de(e=>!e);else if(t===`toggle-fold`)En&&sn(En);else if(t===`hide-reviewed`)V.setHideReviewed(!V.hideReviewed);else if(t===`next-layer`||t===`prev-layer`){if(!Ge)return;let e=Do(je,He,t===`next-layer`?1:-1,Je);e===null?t===`prev-layer`&&Re&&!ze&&$e():Qe(e)}else if(t===`next-decision`){let e=Ke?.decisions;if(!e||e.length===0)return;let t=Pe===null?0:(Pe+1)%e.length;Fe(t);let n=e[t].places.find(e=>e.hunkId);n?pn(n.at.path,n.at.line??null):document.querySelector(`.reading-pane`)?.scrollTo({top:0})}else Dn(t)}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Dn,y,En,un,G,an,yn,sn,V.hideReviewed,V.setHideReviewed,Ge,je,He,Je,Qe,$e,Ie,ze,Ke,Pe,pn]);let On=Oe.filter(e=>!e.derived).length,kn=(0,x.useMemo)(()=>{let e=Ke;if(!e)return;let t=new Map;for(let{file:n,note:r}of e.files)r?t.set(n.path,r):e.kind===`mechanical`&&n.hunks.length>0&&t.set(n.path,`${n.hunks.length} ${n.hunks.length===1?`site`:`sites`}`);return{id:e.id,...e.decisions?{decisions:e.decisions,openDecision:Pe,onOpenDecision:Fe}:{},kicker:e.derived?`Outside the outline`:`Layer ${e.number} of ${On}`,title:e.title,mechanical:e.kind===`mechanical`,...e.derived?{summary:`Files no layer lists: touched after the outline was posted, or left out of it. The agent absorbs them by re-posting.`}:e.summary?{summary:e.summary}:{},missing:e.missing,listed:e.files.length+(e.hidden??0),hidden:e.hidden??0,onJump:pn,notes:t,knownPaths:De.map(e=>e.path)}},[Ke,On,pn,De,Pe]),An=(0,x.useMemo)(()=>{let e=e=>Do(je,He,e,Je),t=e=>e===null?null:{title:Oe[e].title,onGo:()=>Qe(e)};if(Ge&&ze)return{text:Le?`overview · the description`:`overview · the guide`,title:Le?`the author’s description of this change; ] enters the first layer`:`the agent’s orientation to this change; ] enters the first layer`,progress:null,prev:null,next:t(e(1))};let n=Ke;if(!n)return;let r=wo(n,u),i=n.derived?`since your review`:`layer ${n.number} / ${On}`,a=r.files===0?`nothing here`:r.doneFiles===r.files?`read`:`${r.files-r.doneFiles} left`,o=e(-1);return{text:`${i} · ${r.files} ${r.files===1?`file`:`files`} · ${a}`,title:`${r.doneFiles} of ${r.files} files in this layer marked reviewed`,progress:r.marks===0?0:r.doneMarks/r.marks,stats:To(n),prev:o===null?Re?{title:`Overview`,onGo:$e}:null:t(o),next:t(e(1))}},[Ge,ze,Ke,u,Oe,je,He,Je,On,Qe,$e,Le,Re]),jn=r===`waiting`?`noagent`:l??`quiet`;return t?(0,S.jsxs)(`div`,{className:`center-note`,children:[(0,S.jsx)(Ba,{size:44,className:`center-mark`}),(0,S.jsx)(`div`,{className:`shimmer`}),(0,S.jsx)(`div`,{className:`shimmer shimmer-short`}),`Reading the changeset…`]}):n?(0,S.jsxs)(`div`,{className:`center-note center-note-error`,children:[(0,S.jsx)(Tt,{}),(0,S.jsx)(U,{name:`alert`,size:`lg`}),(0,S.jsx)(`h2`,{children:`Diffo couldn't read this changeset`}),(0,S.jsx)(`p`,{children:n.message}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>location.reload(),children:`Try again`})]}):e?(0,S.jsx)(ds.Provider,{value:Se,children:(0,S.jsxs)(`div`,{className:`layout`,children:[(0,S.jsx)(co,{changeset:e,agent:{presence:r,reason:i,since:a,activity:vt,onInvite:()=>z(!0),batch:gt,suggestion:!ke&&l===null&&I?.layersSuggested?{reason:I.layersSuggested.reason,onOutline:rt}:void 0,monitorOpen:yt,onOpenMonitor:bt,monitorPanel:(0,S.jsx)(Lc,{stillTo:pt.stillTo,back:pt.back,onOpen:e=>{bt(!1),bn(xn(e))},onClose:()=>bt(!1)})},review:{openComments:W,publicDrafts:Vt,onFinishReview:()=>se(!0)},settings:{theme:B,onSetTheme:fe,critter:pe,onSetCritter:me,...he.status?{onShowPrivacy:()=>_e(!0)}:{},onShowShortcuts:()=>de(!0)}}),(0,S.jsxs)(`div`,{ref:N,className:`body${D?` nav-hidden`:``}${j?` rail-dragging`:``}`,style:{"--rail-w":`${P.current}px`},children:[(0,S.jsx)(us,{tab:ve,onSetTab:ye,fileCount:e.files.length,wantsYou:Et,threadCount:Dt,settledCount:kt,layerCount:ke?On:null,layersSuggested:I?.layersSuggested!==void 0,layers:ke?(0,S.jsx)(cs,{layers:je,activeIndex:He,onPick:Qe,viewed:u,guide:Ie,description:Le,overviewActive:ze,onOpenGuide:Re?$e:void 0,threads:wt,attention:Ct,changed:Ee.changed,selectedPath:En,onPickFile:fn,onToggleFileViewed:un,onMarkFiles:_n,onClearFiles:vn,onAskFile:e=>{it(e),re(e)},onRefresh:Ce?rt:void 0,request:Ce?l:null}):(0,S.jsx)(ls,{state:jn,onOutline:rt,onInvite:()=>z(!0)}),files:(0,S.jsx)(ns,{files:De,viewed:u,selectedPath:En,onPickFile:fn,onToggleFileViewed:un,onMarkFiles:_n,onClearFiles:vn,onAskFile:e=>{it(e),re(e)},threads:wt,attention:Ct,changed:Ee.changed,query:V.query,onQuery:V.setQuery,focusTick:be,hideReviewed:V.hideReviewed,onHideReviewed:V.setHideReviewed,hideTests:V.hideTests,onHideTests:V.setHideTests,onlyChanged:we,onOnlyChanged:Te}),threads:(0,S.jsx)(dd,{items:dt,pastItems:xt,pr:Se!==null,selectedThreadId:Rt,totalThreads:I?.threads.length??0,onOpen:e=>bn(xn(e,e.gone===!0)),onResolve:ee.resolve,onReopen:ee.reopen,onDelete:ee.remove,onClearAll:()=>le(!0)})}),(0,S.jsx)(`div`,{className:`rail-resize`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize file list`,"aria-valuemin":$d,"aria-valuemax":ef,"aria-valuenow":k,tabIndex:0,"data-tip":`Drag to resize · double-click (or Home) to reset`,onPointerDown:tn,onDoubleClick:nn,onKeyDown:e=>{e.key===`ArrowLeft`?(e.preventDefault(),en(P.current-16)):e.key===`ArrowRight`?(e.preventDefault(),en(P.current+16)):(e.key===`Home`||e.key===`Enter`)&&(e.preventDefault(),nn())}}),(0,S.jsx)(wu,{files:ot,delta:Tn,landed:Jt,sinceReview:Ee.changedHunkIds,hasMore:Ye<qe.length,onLoadMore:Ze,layer:kn,overview:Ge&&ze,controls:{layer:An,navHidden:D,onToggleNav:an,left:g.total-g.viewed,total:g.total,hunksRead:h.viewed,hunksTotal:h.total,hunkAt:y?G.findIndex(e=>e.id===y)+1:0,hunkCount:G.length,query:V.query,onClearQuery:()=>V.setQuery(``),hiddenQuery:Ge?0:V.hiddenQuery,hideReviewed:V.hideReviewed,onHideReviewed:V.setHideReviewed,hideTests:V.hideTests,onHideTests:V.setHideTests,testCount:V.testCount,onlyChanged:V.onlyChanged,onOnlyChanged:V.setOnlyChanged,changedCount:V.changedCount,hiddenTests:Ge?Ke?.hidden??0:V.hiddenTests,hiddenReviewed:Ge?0:V.hiddenReviewed,hiddenUnchanged:Ge?0:V.hiddenUnchanged,pinned:V.pinned,onSweep:V.unpin,onShowAll:V.showAll,scopeLeft:V.scope.left,scopeTotal:V.scope.total,excludedTests:V.scope.excludedTests,excludedUnchanged:V.scope.excludedUnchanged,onIncludeExcluded:()=>{V.scope.excludedTests>0&&V.setHideTests(!1),V.scope.excludedUnchanged>0&&Te(!1)},onFinish:()=>se(!0),stats:e.stats,unsent:W,viewMode:_,onSetViewMode:v,allCollapsed:T.size>=e.files.length&&e.files.length>0,onToggleCollapseAll:()=>E(t=>t.size>=e.files.length?new Set:new Set(e.files.map(e=>e.path)))},viewed:u,onToggleFileViewed:un,selectedId:y,onSelect:b,viewMode:_,collapsed:T,onToggleCollapsed:sn,comments:gn})]}),oe&&(e.pr?(0,S.jsx)(Ou,{coverage:Gt,presence:r,onFinish:$t,onInvite:()=>{se(!1),z(!0)},onClose:()=>se(!1)}):(0,S.jsx)(Pt,{coverage:Gt,presence:r,checkOff:Yt,onResolve:Zt,onReopen:Qt,onFinish:$t,onInvite:()=>{se(!1),z(!0)},onClose:()=>se(!1)})),ce&&(0,S.jsx)(jt,{total:I?.threads.length??0,past:ct.length,outdated:ct.filter(e=>e.github?.outdated===!0).length,onClear:Kt,onClose:()=>le(!1)}),(0,S.jsx)(Ot,{notices:Cn.notices,onOpen:Cn.open,onDismiss:Cn.dismiss,onClear:Cn.clear,onOpenMonitor:()=>bt(!0)}),he.status&&(0,S.jsx)(Qu,{status:he.status,onShown:he.markShown,onAcknowledge:he.acknowledge}),ge&&he.status&&(0,S.jsx)(Vc,{status:he.status,onSetEnabled:he.setEnabled,onClose:()=>_e(!1)}),ue&&(0,S.jsx)(Eu,{onClose:()=>de(!1)}),R&&(0,S.jsx)(lo,{presence:r,reason:i,onClose:()=>z(!1)}),(0,S.jsx)(Bu,{files:e?.files??lf,onJump:mn})]})}):null}function mf(){return(0,S.jsxs)(T,{client:Xd,children:[(0,S.jsx)(Tt,{}),(0,S.jsx)(pf,{})]})}var hf=400,gf=300;function _f(){let e=(0,x.useRef)(null);return(0,x.useEffect)(()=>{let t=e.current;if(!t)return;let n=null,r=!1,i,a=-1/0,o=null,s=()=>{if(!n)return;let e=n.getAttribute(`data-tip`);if(!e){l();return}t.textContent=e;let r=n.getBoundingClientRect(),i=t.offsetWidth,a=t.offsetHeight,o=Math.max(8,Math.min(r.left+r.width/2-i/2,window.innerWidth-i-8)),s=r.top-a-7,c=s<8?r.bottom+7:s;t.style.left=`${Math.round(o)}px`,t.style.top=`${Math.round(c)}px`},c=()=>{n&&(r=!0,o?.disconnect(),o=new MutationObserver(s),o.observe(n,{attributes:!0,attributeFilter:[`data-tip`]}),s(),r&&t.classList.add(`tip-on`))},l=()=>{i!==void 0&&clearTimeout(i),i=void 0,o?.disconnect(),o=null,r&&(a=performance.now()),r=!1,n=null,t.classList.remove(`tip-on`)},u=(e,t)=>{if(e===n)return;let o=r||performance.now()-a<gf;l(),n=e,t||o?c():i=setTimeout(c,hf)},d=e=>{let t=e.target.closest?.(`[data-tip]`);t instanceof HTMLElement?u(t,!1):l()},f=e=>{let t=e.target.closest?.(`[data-tip]`);t instanceof HTMLElement&&t.matches(`:focus-visible`)?u(t,!0):l()},p=()=>{requestAnimationFrame(()=>{n&&!n.isConnected?l():s()})},m=e=>{e.key===`Escape`&&l()};return document.addEventListener(`pointerover`,d,!0),document.addEventListener(`focusin`,f,!0),document.addEventListener(`focusout`,l,!0),document.addEventListener(`click`,p,!0),document.addEventListener(`scroll`,l,!0),document.addEventListener(`keydown`,m,!0),window.addEventListener(`resize`,l),()=>{l(),document.removeEventListener(`pointerover`,d,!0),document.removeEventListener(`focusin`,f,!0),document.removeEventListener(`focusout`,l,!0),document.removeEventListener(`click`,p,!0),document.removeEventListener(`scroll`,l,!0),document.removeEventListener(`keydown`,m,!0),window.removeEventListener(`resize`,l)}},[]),(0,S.jsx)(`div`,{ref:e,className:`tip`,"aria-hidden":`true`})}kd(Dd()),(0,nt.createRoot)(document.getElementById(`root`)).render((0,S.jsxs)(x.StrictMode,{children:[(0,S.jsx)(mf,{}),(0,S.jsx)(_f,{})]}));export{u as a,s as i,fr as n,l as o,o as r,X as t};