@diffohq/diffo 0.18.0 → 0.18.1
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.
- package/dist/cli.mjs +25 -3
- package/dist/client/assets/{abnfDiagram-WEYOIA3C-B6Y8XL3T.js → abnfDiagram-WEYOIA3C-BITPutiq.js} +1 -1
- package/dist/client/assets/{arc-BMKLX6de.js → arc-XLwEHJAC.js} +1 -1
- package/dist/client/assets/{architecture-WOLXFQ4H-GCPjgG_6.js → architecture-WOLXFQ4H-BZeBS7vX.js} +1 -1
- package/dist/client/assets/{architectureDiagram-ZHVYKT53-D0haekvL.js → architectureDiagram-ZHVYKT53-CoP26SlW.js} +1 -1
- package/dist/client/assets/{blockDiagram-RJAE7QA3-9ozRFq3h.js → blockDiagram-RJAE7QA3-BzOd9ivC.js} +1 -1
- package/dist/client/assets/{c4Diagram-XDPPPE54-3atKbk2-.js → c4Diagram-XDPPPE54-lN1g2nbS.js} +1 -1
- package/dist/client/assets/channel-DI_venIK.js +1 -0
- package/dist/client/assets/{chunk-2E7WHVMD-B-hVLdxW.js → chunk-2E7WHVMD-BH_-CWp4.js} +1 -1
- package/dist/client/assets/{chunk-4EMNKR2T-9R_Ywqe-.js → chunk-4EMNKR2T-B6lY_NOq.js} +1 -1
- package/dist/client/assets/{chunk-55XCU76K-CRfSz7WS.js → chunk-55XCU76K-jxnWQEEf.js} +1 -1
- package/dist/client/assets/{chunk-7S6XSTFO-jZvVFXd4.js → chunk-7S6XSTFO-BNGH3Dvb.js} +1 -1
- package/dist/client/assets/{chunk-AQDTSKZB-DM1KPnfu.js → chunk-AQDTSKZB-Bj4tRXLd.js} +1 -1
- package/dist/client/assets/{chunk-DSNLSHJZ-D-0UEL_k.js → chunk-DSNLSHJZ-dqouHFOm.js} +1 -1
- package/dist/client/assets/{chunk-HAGFOTED-C_UwN40v.js → chunk-HAGFOTED-WU-kuZyO.js} +1 -1
- package/dist/client/assets/{chunk-HNE4Q36P-Ng5JYsLi.js → chunk-HNE4Q36P-DDj4a4VY.js} +1 -1
- package/dist/client/assets/{chunk-NQOKRVIF-BGCe7Zmm.js → chunk-NQOKRVIF-CinmJ3jB.js} +1 -1
- package/dist/client/assets/{chunk-UHW7PFBP-Hz5urMmR.js → chunk-UHW7PFBP-DXDZHSL0.js} +1 -1
- package/dist/client/assets/{chunk-VQ5W62QI-CvIK79s8.js → chunk-VQ5W62QI-D6e5gB46.js} +1 -1
- package/dist/client/assets/{chunk-WQQL4CDK-DP0cdd_-.js → chunk-WQQL4CDK-DyFwHbuI.js} +1 -1
- package/dist/client/assets/{chunk-XXDRQBXY-dz3bjW-Z.js → chunk-XXDRQBXY-DrA7llcC.js} +1 -1
- package/dist/client/assets/{chunk-YZO67HFG-BGaQ4Np3.js → chunk-YZO67HFG-BnBMxlLU.js} +1 -1
- package/dist/client/assets/{chunk-ZAUX2LTX-CaHpxHrZ.js → chunk-ZAUX2LTX-CkQBgGiK.js} +1 -1
- package/dist/client/assets/{chunk-ZCHMQSOR-BQAh24-J.js → chunk-ZCHMQSOR-DCaSZNV0.js} +1 -1
- package/dist/client/assets/{classDiagram-v2-4MYWR3UA-C1uGZilp.js → classDiagram-v2-4MYWR3UA-DzsXHg4h.js} +1 -1
- package/dist/client/assets/{core-DmmPKspM.js → core-ocswKbjM.js} +1 -1
- package/dist/client/assets/{cose-bilkent-JH36ORCC-CA0uoIGo.js → cose-bilkent-JH36ORCC-f856-NuP.js} +1 -1
- package/dist/client/assets/{cynefin-EF2NZ3EQ-D7-HiRmU.js → cynefin-EF2NZ3EQ-DdedDlfF.js} +1 -1
- package/dist/client/assets/{cynefinDiagram-WF24UDRP-Ct_qs0cP.js → cynefinDiagram-WF24UDRP-BjKxMBU7.js} +1 -1
- package/dist/client/assets/{dagre-NK4GIZVX-Cffqg6NJ.js → dagre-NK4GIZVX-CBKiapHn.js} +1 -1
- package/dist/client/assets/{diagram-CBK3MWTC-ByBNedZy.js → diagram-CBK3MWTC-DFsb40R6.js} +1 -1
- package/dist/client/assets/{diagram-I5XIIV2D-ByMRPZMW.js → diagram-I5XIIV2D-DhJibXln.js} +1 -1
- package/dist/client/assets/{diagram-ODIL2UCW-C0OayomU.js → diagram-ODIL2UCW-C-h6vvat.js} +1 -1
- package/dist/client/assets/{diagram-PFBEJUXE-BezcNJg0.js → diagram-PFBEJUXE-DPuLFhTR.js} +1 -1
- package/dist/client/assets/{diagram-RJA3I4VV-Bl3cl2pD.js → diagram-RJA3I4VV-Tu3F0QAs.js} +1 -1
- package/dist/client/assets/{diagram-TYUNFSNR-CyGZb5mO.js → diagram-TYUNFSNR-BIuRklwy.js} +1 -1
- package/dist/client/assets/{dist-Uc27UV0T.js → dist-BhcyxeU7.js} +1 -1
- package/dist/client/assets/{dist-YWSBp2hZ.js → dist-CmSi3yif.js} +1 -1
- package/dist/client/assets/{ebnfDiagram-V4P3TTPT-11k4sRCB.js → ebnfDiagram-V4P3TTPT-CW5Ty2iw.js} +1 -1
- package/dist/client/assets/{elk-QONTBCTQ-DM4AV9FF.js → elk-QONTBCTQ-C79QiHN2.js} +1 -1
- package/dist/client/assets/{engine-oniguruma-MxRvz1no.js → engine-oniguruma-BZHOTLBc.js} +1 -1
- package/dist/client/assets/{erDiagram-KYQIGQAA-D38TGssZ.js → erDiagram-KYQIGQAA-D1q58bbD.js} +1 -1
- package/dist/client/assets/{eventmodeling-K75KTNOO-DF0H3qdx.js → eventmodeling-K75KTNOO-D9k7Dc2v.js} +1 -1
- package/dist/client/assets/flowDiagram-IUGLLWBU-CooVKzeE.js +1 -0
- package/dist/client/assets/{ganttDiagram-R7GPNTJY-DXtKy5K6.js → ganttDiagram-R7GPNTJY-v1-_7dtl.js} +1 -1
- package/dist/client/assets/{gitGraph-VSP46ZUC-BJmPpwux.js → gitGraph-VSP46ZUC-BkCTcoI4.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-PDYL7XHY-FwrK2brd.js → gitGraphDiagram-PDYL7XHY-B_3781fy.js} +1 -1
- package/dist/client/assets/{index-_VrQDc2L.js → index-Cl1WBexq.js} +4 -4
- package/dist/client/assets/{info-OHQRW6UA-W1kRy4TV.js → info-OHQRW6UA-DMdGuJ_6.js} +1 -1
- package/dist/client/assets/{infoDiagram-MVDRKAX5-giO2ZEe8.js → infoDiagram-MVDRKAX5-BhZTwiET.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-HPEHV2GE-DTOlB5LG.js → ishikawaDiagram-HPEHV2GE-BNASStxk.js} +1 -1
- package/dist/client/assets/{journeyDiagram-BOSHW7O7-DqENuBSc.js → journeyDiagram-BOSHW7O7-DBri9OM7.js} +1 -1
- package/dist/client/assets/{kanban-definition-FNSA4HC5-CIYIECg_.js → kanban-definition-FNSA4HC5-CB99swIS.js} +1 -1
- package/dist/client/assets/{line-D_x4AjTF.js → line-CNWjW33V.js} +1 -1
- package/dist/client/assets/{linear-CS4Fq7f5.js → linear-jiBQNfl6.js} +1 -1
- package/dist/client/assets/{mermaid-parser.core-720dQRcD.js → mermaid-parser.core-LynYB9P7.js} +3 -3
- package/dist/client/assets/{mermaid.core-DNKhW2d1.js → mermaid.core-vlyR5lnz.js} +4 -4
- package/dist/client/assets/{mindmap-definition-6OY57UG3-Tyz7I7bd.js → mindmap-definition-6OY57UG3-C5i5FgNX.js} +1 -1
- package/dist/client/assets/{packet-JDAUHWVQ-CIT4RofU.js → packet-JDAUHWVQ-Cgu-Kqzy.js} +1 -1
- package/dist/client/assets/{pegDiagram-ECIUJNBX-BDv64Oqu.js → pegDiagram-ECIUJNBX-BpcK0g6K.js} +1 -1
- package/dist/client/assets/{pie-XZMESJXO-B7TeMgE-.js → pie-XZMESJXO-BEEJtS0H.js} +1 -1
- package/dist/client/assets/{pieDiagram-GNMPY74T-DZ5ISynf.js → pieDiagram-GNMPY74T-CWiskC_G.js} +1 -1
- package/dist/client/assets/{quadrantDiagram-D57K4MC3-q3ZFhuD4.js → quadrantDiagram-D57K4MC3-CMd-lsFE.js} +1 -1
- package/dist/client/assets/{radar-ABXABTNO-DfOTCpQ-.js → radar-ABXABTNO-BVIACR11.js} +1 -1
- package/dist/client/assets/{railroad-I3PHUGI6-DtLPMTjt.js → railroad-I3PHUGI6-BuRoZQVa.js} +1 -1
- package/dist/client/assets/{railroad-abnf-LNEFI6M7-DPObEtfh.js → railroad-abnf-LNEFI6M7-C7NXl00v.js} +1 -1
- package/dist/client/assets/{railroad-ebnf-DWYD2UWJ-g6Y97jri.js → railroad-ebnf-DWYD2UWJ-vQis1i0J.js} +1 -1
- package/dist/client/assets/{railroad-peg-JR7BVNR7-CfUBWVcL.js → railroad-peg-JR7BVNR7-D425d6aR.js} +1 -1
- package/dist/client/assets/{railroadDiagram-Y72NRBL7-CKGjfL5n.js → railroadDiagram-Y72NRBL7-anbLXBOK.js} +1 -1
- package/dist/client/assets/{requirementDiagram-EQYSW5RA-kfSYKuPQ.js → requirementDiagram-EQYSW5RA-Do0vrmNp.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-SY24JHO5-Dn5ou0D7.js → sankeyDiagram-SY24JHO5-sdv9fmMC.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-BLEHNHQU-B6Qcw9U_.js → sequenceDiagram-BLEHNHQU-orTXjcMI.js} +1 -1
- package/dist/client/assets/{src-Bz4qgR7m.js → src-D88qhP-M.js} +1 -1
- package/dist/client/assets/{stateDiagram-v2-A6IESKWZ-B56x9sAq.js → stateDiagram-v2-A6IESKWZ-BMrKeg24.js} +1 -1
- package/dist/client/assets/{swimlanes-B3ENRKFQ-BCQJqf0x.js → swimlanes-B3ENRKFQ-CzSOVIZd.js} +1 -1
- package/dist/client/assets/swimlanesDiagram-AYQRV4AK-BawZTvFs.js +8 -0
- package/dist/client/assets/{timeline-definition-JXYKGLGB-lEItkXBD.js → timeline-definition-JXYKGLGB-CPgpDSiT.js} +1 -1
- package/dist/client/assets/{treeView-D4JQ5SDB-CYZkbtcm.js → treeView-D4JQ5SDB-DSOtx_d6.js} +1 -1
- package/dist/client/assets/{treemap-SAJKECNS-B96tHxAb.js → treemap-SAJKECNS-v6xOF3AB.js} +1 -1
- package/dist/client/assets/{usecaseDiagram-WPOLBNNX-CvTDEhna.js → usecaseDiagram-WPOLBNNX-vIU2QZRD.js} +1 -1
- package/dist/client/assets/{vennDiagram-Q3Y3IDCW-C2Ix7bQn.js → vennDiagram-Q3Y3IDCW-BcY09aXA.js} +1 -1
- package/dist/client/assets/{wardley-7MLQ67FV-EAIVeoto.js → wardley-7MLQ67FV-D8Eua27h.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-IVAIDKWA--Okbz3eY.js → wardleyDiagram-IVAIDKWA-B1-GpplK.js} +1 -1
- package/dist/client/assets/{xychartDiagram-4URNHDU4-CpPxhDeV.js → xychartDiagram-4URNHDU4-CjNvVw7U.js} +1 -1
- package/dist/client/index.html +1 -1
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/dist/client/assets/channel-CY0_tHjG.js +0 -1
- package/dist/client/assets/flowDiagram-IUGLLWBU-rSziK2Bd.js +0 -1
- package/dist/client/assets/swimlanesDiagram-AYQRV4AK-C1YHgM4T.js +0 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-vlyR5lnz.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-D88qhP-M.js","assets/chunk-DSNLSHJZ-dqouHFOm.js","assets/chunk-7S6XSTFO-BNGH3Dvb.js","assets/dist-BhcyxeU7.js","assets/chunk-YZO67HFG-BnBMxlLU.js","assets/chunk-AQDTSKZB-Bj4tRXLd.js","assets/chunk-DUW6YSOI-Dgx8z5s3.js","assets/chunk-UHW7PFBP-DXDZHSL0.js","assets/chunk-HAGFOTED-WU-kuZyO.js","assets/chunk-J5ZVWO5B-oDCd-gWO.js","assets/rough.esm-Dy-Kn_BL.js","assets/chunk-ZAUX2LTX-CkQBgGiK.js","assets/chunk-WQQL4CDK-DyFwHbuI.js","assets/line-CNWjW33V.js","assets/path-fybaL0A-.js","assets/array-BifhSqXX.js","assets/chunk-HNE4Q36P-DDj4a4VY.js","assets/c-Cz4nF6n_.js","assets/c-SSSlmE39.js","assets/cpp-DzjeI0uH.js","assets/cpp-Cts1PyIS.js","assets/css-DgaLhXQH.js","assets/css-BGIxQoYs.js","assets/html-BWDvXlHg.js","assets/html-BMn1ogTm.js","assets/javascript-BzbQS41l.js","assets/java-_ATy9zCa.js","assets/java-BtIQNnN0.js","assets/javascript-CpIGwZ_Y.js","assets/json-C3WlssX3.js","assets/json-B88Oqtu5.js","assets/jsx-C4yDKi0A.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-CVTB3cr6.js","assets/sql-CfM2IJm3.js","assets/svelte-DAcAPYhA.js","assets/tsx-CGosfAUg.js","assets/typescript-Bb1J8qyy.js","assets/vue-rALd9gPk.js","assets/xml-DuKfbPI6.js","assets/yaml-DDA_XMNu.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 ee(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 I=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 L(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,I)}catch(e){I(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function te(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 L(te.bind(null,e))}var ne={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=ne,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=te,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:ee}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=L,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.1`})),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.1`})),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`),ee=Symbol.for(`react.forward_ref`),I=Symbol.for(`react.suspense`),L=Symbol.for(`react.suspense_list`),te=Symbol.for(`react.memo`),ne=Symbol.for(`react.lazy`),re=Symbol.for(`react.activity`),R=Symbol.for(`react.legacy_hidden`),ie=Symbol.for(`react.memo_cache_sentinel`),ae=Symbol.for(`react.view_transition`),oe=Symbol.for(`react.recoverable`),se=Symbol.iterator;function ce(e){return typeof e!=`object`||!e?null:(e=se&&e[se]||e[`@@iterator`],typeof e==`function`?e:null)}var le=Symbol.for(`react.client.reference`);function ue(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===le?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 I:return`Suspense`;case L:return`SuspenseList`;case re:return`Activity`;case ae: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 ee:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case te:return t=e.displayName||null,t===null?ue(e.type)||`Memo`:t;case ne:t=e._payload,e=e._init;try{return ue(e(t))}catch{}}return null}var de=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 Oe(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 V=!1;function ke(e,t){if(!e||V)return``;V=!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,16 +76,16 @@ ${e}</tr>
|
|
|
76
76
|
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+Hi(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function sa(e,t){return oa.parse(e,t)}sa.options=sa.setOptions=function(e){return oa.setOptions(e),sa.defaults=oa.defaults,yr(sa.defaults),sa},sa.getDefaults=_r,sa.defaults=vr;function ca(...e){return oa.use(...e),sa.defaults=oa.defaults,yr(sa.defaults),sa}sa.use=ca,sa.walkTokens=function(e,t){return oa.walkTokens(e,t)},sa.parseInline=oa.parseInline,sa.Parser=ra,sa.parser=ra.parse,sa.Renderer=ta,sa.TextRenderer=na,sa.Lexer=ea,sa.lexer=ea.lex,sa.Tokenizer=$i,sa.Hooks=ia,sa.parse=sa,sa.options,sa.setOptions,sa.walkTokens,sa.parseInline,ra.parse,ea.lex,sa.setOptions({gfm:!0,breaks:!0});var la=[`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`],ua=gr(),da=!1;function fa(){da||(da=!0,ua.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 pa(e){fa();let t=sa.parse(e,{async:!1});return ua.sanitize(t,{ALLOWED_TAGS:la,ALLOWED_ATTR:[`href`,`title`,`target`,`rel`,`class`],ALLOWED_URI_REGEXP:/^(?:https?:|mailto:|#)/i})}var ma=[...la,`img`,`picture`,`source`,`div`,`span`,`details`,`summary`],ha=gr(),ga=``;function _a(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 va(e){return`/api/file?path=${encodeURIComponent(_a(ga,e))}&side=head`}var ya=/^(?:[a-z][a-z0-9+.-]*:|\/\/|#)/i,ba=/^(?:https?:|mailto:|#)/i,xa=!1;function Sa(){xa||(xa=!0,ha.addHook(`uponSanitizeAttribute`,(e,t)=>{let{attrName:n,attrValue:r}=t;n===`src`||n===`href`?ya.test(r)?ba.test(r)||(t.keepAttr=!1):t.attrValue=va(r):n===`srcset`&&(t.attrValue=r.split(`,`).map(e=>{let[t,...n]=e.trim().split(/\s+/);return t?ya.test(t)?ba.test(t)?[t,...n].join(` `):``:[va(t),...n].join(` `):``}).filter(Boolean).join(`, `))}),ha.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 Ca(e,t){Sa();let n=t.lastIndexOf(`/`);ga=n===-1?``:t.slice(0,n);let r=sa.parse(e,{async:!1});return ha.sanitize(r,{ALLOWED_TAGS:ma,ALLOWED_ATTR:[`href`,`title`,`target`,`rel`,`class`,`src`,`srcset`,`alt`,`width`,`height`,`media`,`align`,`open`]})}function wa(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 Ta(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`})}function Ea({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)(W,{name:`check`,size:`sm`})})}var Da=()=>{let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`?!0:e===`light`?!1:window.matchMedia?.(`(prefers-color-scheme: dark)`).matches??!1};function Oa(){let[e,t]=(0,x.useState)(()=>typeof window<`u`&&Da());return(0,x.useEffect)(()=>{let e=()=>t(Da()),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 ka(e){return`file-${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}`}function Aa(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 ja=[/[._-](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 Ma(e){return ja.some(t=>t.test(e))}var Na=`diffo:ui:hideReviewed`,Pa=`diffo:ui:hideTests`;function Fa(e){let t=localStorage.getItem(e);return t===`1`||t!==`0`&&null}function Ia(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&&Ma(s.path)){e||(i++,o.push(s.path));continue}}r++,e||n++}return{left:n,total:r,excludedTests:i,excludedUnchanged:a,excludedPaths:o}}function La(e,t){let n=[],r=t.query.trim().toLowerCase(),i=0,a=0,o=0,s=0;for(let c of e)t.pinned.has(c.path)?n.push(c):r!==``&&!c.path.toLowerCase().includes(r)?s++:t.onlyChanged&&!t.changed.has(c.path)?o++:t.hideTests&&Ma(c.path)?i++:t.hideReviewed&&t.isDone(c)?a++:n.push(c);return{visible:n,hiddenTests:i,hiddenReviewed:a,hiddenUnchanged:o,hiddenQuery:s}}function Ra(e,t,n){let[r,i]=(0,x.useState)(()=>Fa(Na)),[a,o]=(0,x.useState)(()=>Fa(Pa)),[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(Na,e?`1`:`0`),i(e),c(new Set)},[]),h=(0,x.useCallback)(e=>{localStorage.setItem(Pa,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(Na,`0`),localStorage.setItem(Pa,`0`),i(!1),o(!1),c(new Set),u(``),v(!1)},[v]),b=(0,x.useMemo)(()=>La(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=>Ma(e.path)).length,[e]),C=(0,x.useMemo)(()=>Ia(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 za=e=>e.slice(e.lastIndexOf(`/`)+1),Ba={added:`new file`,deleted:`deleted`,renamed:`renamed`,modified:`edited`};function Va(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)=>za(e.file.path).localeCompare(za(t.file.path)));return[...t,...r]};return n(t)}function Ha(e){return e.kind===`file`?[e.file]:e.children.flatMap(Ha)}function Ua(e){return Va(e).flatMap(Ha)}function Wa({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)(Ea,{state:n})}),(0,S.jsx)(`button`,{type:`button`,className:`row-pick`,title:`${e.path} · ${Ba[e.status]}${n?` · read`:``}${m}${s?`, ${s}`:``}`,onClick:()=>{if(c)return c();let t=document.getElementById(ka(e.path));t&&Aa(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:[za(e.oldPath),` →`]}),(0,S.jsx)(`span`,{className:`row-base${e.status===`deleted`?` row-base-del`:``}`,children:za(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)(W,{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)(W,{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)(W,{name:`chat`,size:`sm`})})})]})]})}function Ga({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=>zt(e,t),[t]),g=(0,x.useMemo)(()=>Va(e),[e]),_=(e,t)=>(0,S.jsx)(Wa,{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=Ha(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)(Ea,{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)(W,{name:`chev`,size:`sm`})}),(0,S.jsx)(`span`,{className:`dir-ico`,children:(0,S.jsx)(W,{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 Ka({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=>zt(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&&Ma(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)(W,{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)(W,{name:`x`,size:`sm`})})]})}),(0,S.jsxs)(`div`,{className:`rail-scroll`,children:[(0,S.jsx)(Ga,{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 qa=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function Ja(e,t){let n=0,r=0,i=0;for(let a of e){let e=Lt(a);n+=e.length,r+=e.filter(e=>t.has(e)).length,zt(a,t)&&i++}return{files:e.length,doneFiles:i,marks:n,doneMarks:r}}function Ya({commit:e,files:t,current:n,open:r,onToggleOpen:i,viewed:a,threadCount:o,onPick:s,onMarkFiles:c,onClearFiles:l}){let u=t?Ja(t,a):null,d=u!==null&&u.files>0&&u.doneFiles===u.files,f=u!==null&&u.doneMarks>0,p=(t??[]).filter(e=>!zt(e,a)),m=e.sha===gt,{additions:h,deletions:g}=e.stats,_=[e.short,e.author,e.at?wa(e.at):null].filter(Boolean).join(` · `);return(0,S.jsxs)(`div`,{className:`row row-layer row-commit${d?` row-done`:``}${m?` row-layer-since`:``}`,"aria-current":n?`true`:void 0,"data-commit":e.sha,onClick:s,children:[(0,S.jsx)(`button`,{type:`button`,className:`row-box`,role:`checkbox`,"aria-checked":d?!0:f?`mixed`:!1,"aria-label":d?`Mark ${e.subject} not reviewed`:`Mark ${qa(p.length,`file`)} in ${e.subject} reviewed`,"data-tip":d?`Mark commit not reviewed`:`Mark commit reviewed`,disabled:!t||t.length===0||(d?!l:!c),onClick:e=>{e.stopPropagation(),t&&(d?l?.(t):c?.(p))},children:(0,S.jsx)(Ea,{state:d?!0:f?`mixed`:!1})}),(0,S.jsxs)(`button`,{type:`button`,className:`row-pick`,title:e.body?`${e.subject}\n\n${e.body}`:e.subject,onClick:e=>{e.stopPropagation(),s()},children:[(0,S.jsx)(`span`,{className:`row-name`,children:(0,S.jsx)(`span`,{className:`row-base`,children:e.subject})}),(0,S.jsxs)(`span`,{className:`ch-sub`,children:[u!==null&&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.jsxs)(`span`,{children:[_&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`commit-who`,children:_}),` · `]}),qa(e.stats.files,`file`),(h>0||g>0)&&(0,S.jsxs)(S.Fragment,{children:[` · `,h>0&&(0,S.jsxs)(`span`,{className:`stat-add`,children:[`+`,h]}),h>0&&g>0&&` `,g>0&&(0,S.jsxs)(`span`,{className:`stat-del`,children:[`−`,g]})]}),d?` · read`:``]})]})]}),(0,S.jsxs)(`span`,{className:`row-right`,children:[o>0&&(0,S.jsxs)(`span`,{className:`row-count`,title:qa(o,`thread`),children:[(0,S.jsx)(W,{name:`chat`,size:`sm`}),o]}),t&&t.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.subject}`,"data-tip":r?`Hide files`:`Show files`,onClick:e=>{e.stopPropagation(),i()},children:(0,S.jsx)(W,{name:`chev`,size:`sm`})})]})]})}function Xa({commits:e,filesBySha:t,activeSha:n,onPick:r,viewed:i,threads:a,onMarkCommitFiles:o,onClearCommitFiles:s,loading:c=!1,error:l,...u}){let[d,f]=(0,x.useState)(new Set),p=e=>f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),m=e=>(e??[]).reduce((e,t)=>e+(a?.get(t.path)?.length??0),0);return l?(0,S.jsx)(`div`,{className:`rail-empty`,children:l}):e.length===0?(0,S.jsx)(`div`,{className:`rail-scroll`,children:(0,S.jsx)(`div`,{className:`rail-empty`,children:c?`reading the commits…`:`No commits to step through — this review is of uncommitted changes. Open one against a branch to read it commit by commit.`})}):(0,S.jsx)(`div`,{className:`rail-scroll`,children:e.map(e=>{let c=t.get(e.sha),l=d.has(e.sha),f=e.sha===gt;return(0,S.jsxs)(`div`,{className:`ch-layer`,children:[f&&(0,S.jsx)(`div`,{className:`rail-rule`}),(0,S.jsx)(Ya,{commit:e,files:c,current:e.sha===n,open:l,onToggleOpen:()=>p(e.sha),viewed:i,threadCount:m(c),onPick:()=>r(e.sha),onMarkFiles:o,onClearFiles:s}),l&&c&&c.length>0&&(0,S.jsx)(`div`,{className:`ch-files`,children:(0,S.jsx)(Ga,{files:c,viewed:i,...u,threads:a,selectedPath:e.sha===n?u.selectedPath:null,onPickFile:u.onPickFile?t=>{e.sha!==n&&r(e.sha),u.onPickFile?.(t)}:void 0,onToggleFileViewed:u.onToggleFileViewed&&e.sha===n?u.onToggleFileViewed:void 0,onMarkFiles:o?e=>o(c.filter(t=>e.includes(t.path))):void 0,onClearFiles:s?e=>s(c.filter(t=>e.includes(t.path))):void 0})})]},e.sha)})})}var Za=4;function Qa(e){return e.kind===`changeset`?`the whole changeset`:e.kind===`file`?e.path:e.kind===`layer`?`layer “${e.title}”`:`${e.path}:${ht(e)}${e.side===`old`?` (old side)`:``}`}function $a({coverage:e,presence:t,checkOff:n=[],onResolve:r,onReopen:i,onFinish:a,onInvite:o,onClose:s}){let c=Et(!0,e),[l,u]=(0,x.useState)(null),[d,f]=(0,x.useState)(!1),[p,m]=(0,x.useState)(null),[h,g]=(0,x.useState)(!1),[_,v]=(0,x.useState)(!1),[y,b]=(0,x.useState)(!1),[C,w]=(0,x.useState)(``),T=t!==`waiting`,E=c.data?.outgoing??[],D=_?E:E.slice(0,Za),O=E.filter(e=>e.fresh).length,k=E.length-O,A=e.totalFiles!==void 0&&e.totalFiles>0,j=A?e.viewedFiles??0:e.viewedHunks,M=A?e.totalFiles:e.totalHunks,N=A?e.changedFiles?.length??0:0,P=Math.max(0,M-j-N),F=M>0&&j===M,ee=F&&n.length===0&&!c.isLoading&&!c.error&&E.length===0,I=e=>{f(!1),b(!0),a(e,{note:C}).then(async({delivered:t,prompt:n})=>{if(t&&e)return s();u(`copied`),await Ot(n)||m(n)}).catch(()=>f(!0)).finally(()=>b(!1))},L=l?void 0:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,disabled:y,onClick:()=>I(T),children:[(0,S.jsx)(W,{name:T?`send`:`copy`,size:`sm`}),` `,T?`Finish & send`:`Finish & copy prompt`]}),T&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:y,title:`finish the review, but carry the prompt to your agent yourself`,onClick:()=>I(!1),children:`Copy prompt instead`}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:s,children:`Cancel`}),c.data&&(0,S.jsxs)(`span`,{className:`fin-foot-peek`,children:[(0,S.jsx)(`button`,{type:`button`,className:`fin-link`,onClick:()=>g(!h),"aria-expanded":h,children:`view the exact prompt`}),(0,S.jsx)(`button`,{type:`button`,className:`ghb`,"data-tip":`copy the prompt without finishing`,"aria-label":`Copy the prompt without finishing`,onClick:()=>void Ot(c.data.prompt),children:(0,S.jsx)(W,{name:`copy`,size:`sm`})})]})]});return(0,S.jsxs)(Ft,{title:`Finish review`,wide:!0,onClose:s,footer:L,children:[!T&&!l&&(0,S.jsxs)(`div`,{className:`fin-dest`,children:[(0,S.jsx)(`span`,{className:`fin-dest-pip`}),(0,S.jsxs)(`span`,{className:`fin-dest-text`,children:[(0,S.jsx)(`b`,{children:`No agent attached`}),`: finishing copies the prompt for you to paste`]}),(0,S.jsx)(`button`,{type:`button`,className:`fin-link`,onClick:o,children:`Invite an agent`})]}),!l&&n.length>0&&(0,S.jsxs)(`div`,{className:`fin-sect fin-checkoff`,children:[(0,S.jsxs)(`div`,{className:`fin-sect-h`,children:[(0,S.jsx)(`span`,{className:`fin-sect-label`,children:`Still on you`}),(0,S.jsx)(`span`,{className:`fin-sect-n`,children:n.length}),(0,S.jsx)(`span`,{className:`fin-sect-why`,children:`· settle these first; reopened ones join this send`})]}),(0,S.jsx)(`ul`,{className:`fin-rows`,children:n.map(e=>(0,S.jsx)(to,{item:e,onResolve:r,onReopen:i},e.thread.id))})]}),!l&&(c.isLoading||c.error||E.length>0)&&(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:`Going out`}),E.length>0&&(0,S.jsx)(`span`,{className:`fin-sect-n`,children:E.length}),E.length>0&&(0,S.jsx)(`span`,{className:`fin-sect-why`,children:T?`· ${[O>0?`${O} new`:null,k>0?`${k} resent`:null].filter(Boolean).join(` · `)}`:`· in the copied prompt`})]}),c.isLoading&&(0,S.jsx)(`div`,{className:`shimmer`}),c.error&&(0,S.jsxs)(`p`,{className:`cov-note cov-note-error`,children:[`Couldn't read the outgoing batch: `,c.error.message,`. Finishing still works; it just isn't previewed.`]}),E.length>0&&(0,S.jsxs)(`ul`,{className:`fin-rows`,children:[D.map(e=>(0,S.jsx)(no,{thread:e},e.id)),E.length>Za&&(0,S.jsx)(`li`,{className:`fin-rows-span`,children:(0,S.jsxs)(`button`,{type:`button`,className:`fin-more`,onClick:()=>v(!_),children:[(0,S.jsx)(W,{name:`chev`,size:`sm`}),_?`Show fewer`:`${E.length-Za} more`]})})]})]}),!l&&M>0&&(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:`Your coverage`}),!ee&&(0,S.jsx)(`span`,{className:`fin-sect-why`,children:`· sent as-is, never a gate`})]}),(0,S.jsxs)(`div`,{className:`fin-cov-bar`,children:[(0,S.jsx)(`i`,{className:`fin-cov-read`,style:{width:`${j/M*100}%`}}),(0,S.jsx)(`i`,{className:`fin-cov-moved`,style:{width:`${N/M*100}%`}})]}),(0,S.jsxs)(`div`,{className:`fin-cov-status`,children:[(0,S.jsxs)(`span`,{className:F?`fin-cov-ok`:``,children:[(0,S.jsx)(`i`,{className:`fin-cov-sw fin-cov-sw-read`}),F?`all ${M} ${A?`files`:`hunks`} read`:`${j} of ${M} read`]}),N>0&&(0,S.jsxs)(`span`,{className:`fin-cov-attn`,children:[(0,S.jsx)(`i`,{className:`fin-cov-sw fin-cov-sw-moved`}),N,` changed since you read `,N===1?`it`:`them`]}),P>0&&(0,S.jsxs)(`span`,{children:[(0,S.jsx)(`i`,{className:`fin-cov-sw fin-cov-sw-unread`}),P,` not read`]}),ee&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`fin-cov-ok`,children:`✓ every thread settled`}),(0,S.jsx)(`span`,{children:`nothing going out`})]})]})]}),!l&&(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:`Your word`}),(0,S.jsx)(`span`,{className:`fin-sect-why`,children:`· optional; sent as a thread on the changeset, so the agent can reply`})]}),(0,S.jsx)(`textarea`,{className:`fin-note`,placeholder:`e.g. "LGTM, ship it", or "fix these, then show me again"`,value:C,rows:2,onChange:e=>w(e.target.value)})]}),h&&c.data&&(0,S.jsx)(`pre`,{className:`invite-prompt`,children:c.data.prompt}),l&&(0,S.jsx)(`p`,{className:`thread-copied`,children:l===`delivered`?`Sent to your agent; replies and fixes will show up here live.`:`Review finished and the prompt copied. Paste it to your agent. Its replies and fixes will show up here live.`}),p&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`warn`,children:[(0,S.jsx)(W,{name:`alert`,size:`sm`}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`b`,{children:`Couldn't reach the clipboard`}),`: this browser blocked it. The review is finished; select the prompt below and copy it by hand.`]})]}),(0,S.jsx)(`pre`,{className:`invite-prompt`,children:p})]}),d&&(0,S.jsx)(`p`,{className:`cov-note cov-note-error`,children:`Couldn't finish the review; the server may be down. Nothing was sent; try again.`})]})}var eo={fixed:`fixed`,answered:`answered`,changed:`changed, no reply`,"no-answer":`no answer`};function to({item:e,onResolve:t,onReopen:n}){let[r,i]=(0,x.useState)(!1),a=t=>{t&&(i(!0),t(e.thread.id).finally(()=>i(!1)))},o=e.outcome?eo[e.outcome]:void 0;return(0,S.jsxs)(`li`,{className:`fin-row fin-row-checkoff`,children:[(0,S.jsx)(`span`,{className:`fin-chip fin-chip-${e.outcome??`waiting`}`,children:o??`back`}),(0,S.jsx)(`span`,{className:`fin-row-anchor${e.gone?` fin-row-anchor-gone`:``}`,title:e.gone?`this file is no longer in the changeset`:void 0,children:e.anchor??`the whole changeset`}),(0,S.jsx)(`span`,{className:`fin-row-text`,children:e.question}),(0,S.jsxs)(`span`,{className:`fin-row-acts`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:r||!t,title:`the agent's answer stands; settle this one`,onClick:()=>a(t),children:[(0,S.jsx)(W,{name:`check`,size:`sm`}),` Done`]}),(0,S.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:r||!n,title:e.gone?`reopen it; it lands in Drafts, and Send on the thread hands it over; the finish batch is scoped to the changeset`:`reopen it; it goes out again in this batch`,onClick:()=>a(n),children:[(0,S.jsx)(W,{name:`undo`,size:`sm`}),` Still not right`]})]})]})}function no({thread:e}){let[t,n]=(0,x.useState)(!1),r=e.text.includes(`
|
|
77
77
|
`)||e.text.length>70;return(0,S.jsxs)(`li`,{className:`fin-row`,children:[(0,S.jsx)(`span`,{className:`fin-chip fin-chip-${e.fresh?`fresh`:`resent`}`,children:e.fresh?`new`:`resent`}),(0,S.jsx)(`span`,{className:`fin-row-anchor`,children:Qa(e.anchor)}),r?(0,S.jsxs)(`button`,{type:`button`,className:`fin-row-open`,"aria-expanded":t,"aria-label":t?`Collapse this comment`:`Show the full comment`,onClick:()=>n(!t),children:[(0,S.jsx)(`span`,{className:t?`fin-row-text fin-row-text-full`:`fin-row-text`,children:e.text}),(0,S.jsx)(W,{name:`chev`,size:`sm`})]}):(0,S.jsx)(`span`,{className:`fin-row-text`,children:e.text})]})}function ro(){return typeof document>`u`?!1:document.querySelector(`meta[name="diffo-env"]`)?.getAttribute(`content`)===`development`}var io=30,ao=22,oo=48,so=1100,co=1500,lo=1.1,uo=3e3,fo=110,po=560,mo=64,ho=90/24,go=io*3.5/24,_o=540/24,vo={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`},yo=new Set([`stand`,`sit`]);function bo(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}var xo=(e,t)=>e+Math.random()*(t-e),So=e=>`translate(${e.x}px, ${e.y}px) scale(${e.s})`;function Co({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)},uo)},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 ee=(0,x.useRef)(t);(0,x.useEffect)(()=>{t===`replied`&&ee.current!==`replied`&&!bo()&&k(`approve`),ee.current=t},[t]);let I=yo.has(E)&&!O;(0,x.useEffect)(()=>{let e=o.current,t=e?.querySelector(`.critter-look`);if(!e||!t)return;if(!I||bo()){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*lo}px, ${o/s*lo*.8}px)`})};return addEventListener(`pointermove`,r),()=>{removeEventListener(`pointermove`,r),cancelAnimationFrame(n),t.style.transform=``}},[I]);let L=Math.max(0,v-io),te=(0,x.useRef)(L);te.current=L;let ne=v>0,re=e===`waiting`||L<mo||bo();(0,x.useEffect)(()=>()=>u.current?.(!1),[]),(0,x.useLayoutEffect)(()=>{!s&&m.current&&(m.current.anim.cancel(),m.current=null)},[s]),(0,x.useEffect)(()=>{if(!ne)return;let t=()=>te.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;i<150?n():(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/_o;return{x:e.left-t.left-ho*i,y:e.top+e.height/30-t.top-r.offsetTop-go*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:So(e)})),{duration:po,easing:`cubic-bezier(0.3, 0.7, 0.4, 1)`,fill:`forwards`});m.current={anim:s,home:n},u(po,r)},x=()=>{p(!1),d(!1)},S=e=>{v(t(),fo,()=>{let t=y();t?(D(`stand`),p(!0),b({x:c(),y:0,s:1},t,!0,()=>{x(),e?.()})):(x(),e?.())})},w=e=>{let n=y();C(t()),D(`stand`),p(!0),d(!0),n?b(n,{x:t(),y:0,s:1},!1,()=>{m.current?.anim.cancel(),m.current=null,p(!1),e()}):(p(!1),e())},E=()=>{if(e===`working`){let e=()=>c()>t()/2?xo(0,t()*.4):xo(t()*.6,t()),n=()=>Math.random()<.5?`inspect`:`write`,r=()=>N.current?f(n(),xo(2500,4e3),r):v(e(),oo,()=>f(n(),xo(2500,5e3),()=>Math.random()<.4?f(`think`,xo(1500,2800),r):r()));f(n(),xo(1500,3e3),r)}else{let e=()=>{let n=Math.random();N.current?f(n<.5?`stand`:`read`,xo(3e3,6e3),e):n<.3?f(`read`,xo(4e3,8e3),e):n<.5?f(`stand`,xo(3e3,6e3),e):n<.75?v(xo(0,t()),ao,e):n<.9?f(`sit`,xo(4e3,8e3),e):f(`think`,xo(2e3,3500),e)};f(`read`,xo(3e3,5e3),e)}},j=()=>u(Math.max(e===`working`?xo(300,700):xo(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`?so:co,()=>{O===`approve`&&(g.current=!0),k(null)});else if(O)k(null);else if(re)l.current&&!bo()?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()+xo(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,ne,O,P,re,n,d,i]);let R=()=>{!O&&!bo()&&k(`poke`)},ie={transform:So({x:Math.min(b??L,L),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:ie,onPointerEnter:R,children:(0,S.jsx)(wo,{presence:e,act:E})})})}function wo({presence:e,act:t=e===`waiting`?`sleep`:`stand`,size:n=io}){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:vo.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:vo.plus}),(0,S.jsx)(`path`,{className:`critter-eyes critter-eyes-happy`,d:vo.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 To({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:vo[e]})]})}function Eo({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 Do({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)(W,{name:t})}),a&&(0,S.jsx)(`div`,{className:`menu-panel${r===`left`?` menu-panel-left`:``}`,role:`menu`,children:n(()=>o(!1))})]})}function Oo({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)(W,{name:e,size:`sm`}),(0,S.jsx)(`span`,{className:`menu-item-label`,children:a}),n&&(0,S.jsx)(W,{name:`check`,size:`sm`,className:`menu-item-check`}),t&&(0,S.jsx)(`span`,{className:`kbd`,children:t})]})}function ko(){return(0,S.jsx)(`hr`,{className:`menu-sep`})}function Ao({children:e}){return(0,S.jsx)(`div`,{className:`menu-label`,children:e})}function jo({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)(W,{name:`arrow`,size:`sm`,className:`cmp-arrow`}),(0,S.jsx)(`span`,{className:`cmp-side cmp-side-base`,children:o})]})}var Mo={success:`CI passing`,failure:`CI failing`,pending:`CI running`,none:`no checks`,unknown:`checks not visible to your token`};function No(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 Po({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)(W,{name:`user`,size:t?`md`:`sm`})})}var Y=e=>{let t=Ta(e);return/^\d/.test(t)?`${t} ago`:t};function Fo({pr:e}){let[t,n]=(0,x.useState)(!1),r=e.commits.at(-1),i=[Mo[e.checks.state],r?`pushed ${Y(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)(Po,{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)(W,{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)(W,{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)(W,{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:Ta(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)(W,{name:`link`,size:`sm`})]})]})}function Io({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=No(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)(W,{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)(Fo,{pr:e})]})}var Lo={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`},Ro=`the agent is attached but its last poll ended; a send queues and reaches it when it polls again`,zo=`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`,Bo=/^(working on|answered|picked up|outlining) (.+)$/,Vo=e=>e.charAt(0).toUpperCase()+e.slice(1);function Ho(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=Bo.exec(n);return e?{verb:Vo(e[1]),detail:e[2]}:{verb:Vo(n)}}return t===`arriving`?{verb:`Reading`,detail:`the change`}:t===`repolling`?{verb:`Paused`,detail:`sends wait`}:{verb:`Working`}}function Uo(e,t,n){return n?`happy`:e===`waiting`?`shut`:e===`listening`||t===`arriving`||t===`repolling`?`open`:`plus`}function Wo(e,t){return e===`working`?t===`repolling`?Ro:t===`arriving`?zo:Lo[e]:Lo[e]}function Go(e){let t=Math.max(0,Math.round(e/1e3));return t<60?`${t}s`:`${Math.round(t/60)}m`}function Ko({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`}:Ho(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)(To,{eyes:b?`happy`:Uo(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:[` · `,Go(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:Wo(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:`${Lo[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 qo({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)(Eo,{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))}),ro()&&(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)(Io,{pr:e.pr}),(0,S.jsx)(jo,{changeset:e}),t.presence&&m?(0,S.jsx)(Co,{presence:t.presence,reason:t.reason,seat:s,onAway:l,summon:u}):(0,S.jsx)(`span`,{className:`grow`}),t.presence&&(0,S.jsx)(Ko,{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)(W,{name:`globe`,size:`sm`}),` Submit review`,a>0?` (${a})`:``]}):`Finish review${i>0?` (${i})`:``}`}),(0,S.jsx)(Do,{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)(Ao,{children:`Theme`}),(0,S.jsx)(Oo,{icon:`display`,checked:f===`system`,onClick:()=>{e(),p(`system`)},children:`System`}),(0,S.jsx)(Oo,{icon:`sun`,checked:f===`light`,onClick:()=>{e(),p(`light`)},children:`Light`}),(0,S.jsx)(Oo,{icon:`moon`,checked:f===`dark`,onClick:()=>{e(),p(`dark`)},children:`Dark`})]}),h&&(0,S.jsxs)(S.Fragment,{children:[p&&(0,S.jsx)(ko,{}),(0,S.jsx)(Oo,{icon:`sparkle`,checked:m,onClick:()=>{e(),h(!m)},children:`Animations`})]}),g&&(0,S.jsxs)(S.Fragment,{children:[(p||h)&&(0,S.jsx)(ko,{}),(0,S.jsx)(Oo,{icon:`keys`,kbd:`?`,onClick:()=>{e(),g()},children:`Shortcuts`})]}),_&&(0,S.jsxs)(S.Fragment,{children:[(p||h||g)&&(0,S.jsx)(ko,{}),(0,S.jsx)(Oo,{icon:`lock`,onClick:()=>{e(),_()},children:`Privacy`})]})]})})]})}function Jo({presence:e,reason:t,onClose:n}){let{data:r,isLoading:i,error:a}=Tt(!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=>{Ot(e).then(e=>{l(!e),e&&(s(!0),d(!0),setTimeout(()=>s(!1),2500))})};return p===`connected`?(0,S.jsx)(Ft,{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)(Ft,{title:`Connect your agent`,onClose:n,children:[h&&(0,S.jsxs)(`div`,{className:`warn`,children:[(0,S.jsx)(W,{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)(W,{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)(W,{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.`]})]})]})]})}var Yo=`Since your review`;function Xo(e,t){return e.hunks.find(e=>e.lines.some(e=>e.kind!==`del`&&e.newNo===t))}function Zo(e,t){let n=t.get(e.path);if(!n)return{at:e};let r=e.line===void 0?void 0:Xo(n,e.line);return r?{at:e,file:n,hunkId:r.id}:{at:e,file:n}}function Qo(e,t){if(e&&e.length!==0)return e.map(e=>({decision:e,places:(e.at??[]).map(e=>Zo(e,t))}))}function $o(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=ft(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=pt(t);a.push(c?{file:s,note:c}:{file:s})}let s=Qo(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:Yo,files:a.map(e=>({file:e})),missing:[],derived:!0}),i}function es(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 ts(e){return e.id??`since`}function ns(e){return e.filter(e=>e.anchor.kind===`changeset`&<(e)).at(-1)}function rs(e){return e.find(e=>e.github?.kind===`description`)}function is(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 as(e,t){let n=0,r=0,i=0;for(let{file:a}of e.files){let e=Lt(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 os(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 ss(e,t){let n=as(e,t);return n.doneFiles===n.files}function cs(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 ls(e,t){let n=e.findIndex(e=>e.files.length>0&&!ss(e,t));return n===-1?0:n}var us=`#diffo-file:`;function ds(e,t){return`${us}${encodeURIComponent(e)}${t===null?``:`:${t}`}`}function fs(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 ps=/`([^`\n]+)`/g,ms=/^([^\s:`]+?)(?::(\d+)(?:-\d+)?)?$/;function hs(e){let t=e.closest(`a[href], [data-diffo-jump]`);return t?fs(t.getAttribute(`data-diffo-jump`)??t.getAttribute(`href`)??``):null}function gs(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 _s(e,t){return t.length===0?e:e.split(/(```[\s\S]*?```|\[[^\]\n]*\]\([^)\n]*\))/).map((e,n)=>n%2==1?e:e.replace(ps,(e,n)=>{let r=ms.exec(n);if(!r)return e;let i=gs(r[1],t);return i===null?e:`[${e}](${ds(i,r[2]===void 0?null:Number.parseInt(r[2],10))})`})).join(``)}var vs=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function ys(e){if(e.files.length>0)return null;let t=e.hidden??0;return t>0?`${vs(t,`test`)} hidden`:e.missing.length===0?`nothing here now`:`${vs(e.missing.length,`listed file`)} not in the changeset`}function bs({layer:e,viewed:t}){let n=ys(e);if(n!==null)return(0,S.jsx)(`span`,{children:n});let r=e.hidden??0,i=as(e,t),{additions:a,deletions:o}=os(e),s=i.doneFiles===i.files?` · read`:``,c=e.kind===`mechanical`?` · mechanical`:``,l=r>0?` · ${r} hidden`:``;return(0,S.jsxs)(`span`,{children:[vs(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 xs({layer:e,index:t,current:n,open:r,onToggleOpen:i,viewed:a,threadCount:o,onPick:s,onMarkFiles:c,onClearFiles:l}){let u=as(e,a),d=u.files>0&&u.doneFiles===u.files,f=u.doneMarks>0,p=e.files.filter(e=>!zt(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 ${vs(p.length,`file`)} in ${e.title} reviewed`,"data-tip":d?`Mark ${vs(m.length,`file`)} not reviewed`:`Mark ${vs(p.length,`file`)} reviewed`,disabled:m.length===0||(d?!l:!c),onClick:e=>{e.stopPropagation(),d?l?.(m):c?.(p)},children:(0,S.jsx)(Ea,{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)(bs,{layer:e,viewed:a})]})]}),(0,S.jsxs)(`span`,{className:`row-right`,children:[o>0&&(0,S.jsxs)(`span`,{className:`row-count`,title:vs(o,`thread`),children:[(0,S.jsx)(W,{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)(W,{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)(Ga,{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)(Ea,{})}),(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)(xs,{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 ws({source:e,onPick:t,stepCount:n,commitCount:r}){return(0,S.jsxs)(`div`,{className:`src-seg`,role:`radiogroup`,"aria-label":`Read the change by`,children:[(0,S.jsxs)(`button`,{type:`button`,role:`radio`,className:`src-chip`,"aria-checked":e===`steps`,title:`The agent's steps, read in the order it outlined them`,onClick:()=>t(`steps`),children:[`Steps `,n!==null&&(0,S.jsx)(`span`,{className:`tab-n`,children:n})]}),(0,S.jsxs)(`button`,{type:`button`,role:`radio`,className:`src-chip`,"aria-checked":e===`commits`,title:`The branch's commits, oldest first, each against its parent`,onClick:()=>t(`commits`),children:[`Commits `,(0,S.jsx)(`span`,{className:`tab-n`,children:r})]})]})}function Ts({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 steps`}),(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)(W,{name:`list`,size:`sm`}),`Ask the agent for steps`]})]})})}function Es({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 Os(){return(0,x.useContext)(Ds)}function ks(e){return e.state===`resolved`?`resolved`:U(e)?e.state===`open`&&!e.github?`note`:`posted`:dt(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 As(e){return(e.state===`open`||e.withheld===!0)&&!dt(e)&&!U(e)}var js=[`yours`,`unanswered`,`proposed`,`agent`,`note`,`posted`,`resolved`],Ms={yours:`Your turn`,unanswered:`No answer`,proposed:`From the agent`,agent:`Waiting on agent`,note:`Draft`,posted:`On GitHub`,resolved:`Resolved`},Ns=[`yours`,`proposed`,`agent`,`note`,`posted`,`settled`],Ps={yours:`Your turn`,proposed:`From the agent`,agent:`Waiting on the agent`,note:`Drafts`,posted:`On GitHub`,settled:`Settled`};function Fs(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 Is(e){if(e.state===`open`||e.state===`resolved`||U(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 Ls(e){for(let t of e.split(`
|
|
78
78
|
`)){let e=t.trim();if(e!==``)return e}return``}function Rs(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}:${ht(t)}`,path:t.path}}function zs(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 Bs(e){let t=e=>js.indexOf(e.turn),n=e=>e.sort((e,n)=>t(e)-t(n)||n.updatedAt.localeCompare(e.updatedAt));return{github:n(e.filter(e=>U(e.thread))),agent:n(e.filter(e=>!U(e.thread)))}}function Vs(e,t=new Set,n=new Map){return e.map(e=>{let r=[...e.messages].reverse().find(t=>U(e)?t.author===`github`:t.author===`agent`),i=n.get(e.id),a=Is(e);return{thread:e,turn:ks(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:Ls(e.messages[0]?.text??``),answer:r?Ls(r.text):null,...Rs(e),...r?.durationMs===void 0?{}:{durationMs:r.durationMs},updatedAt:e.updatedAt}})}function Hs(e){return e===null?`the changeset`:e.slice(e.lastIndexOf(`/`)+1)}function Us(e,t){let n=e.find(e=>e.working===!0);return n?`working on ${Hs(n.anchor)}`:t===null?e.length>0?`picked up ${e.length} comment${e.length===1?``:`s`}`:null:`answered ${t}`}function Ws(e){let t=new Map;for(let n of Ns){let r=e.filter(e=>Fs(e.turn)===n).sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt));r.length>0&&t.set(n,r)}return t}function Gs(e){return e.filter(e=>e.turn===`yours`||e.turn===`unanswered`).length}function Ks(e){return e.filter(e=>Fs(e.turn)!==`settled`).length}function qs(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 Js=`modulepreload`,Ys=function(e){return`/`+e},Xs={},Zs=function(e){return e.pathname.endsWith(`.css`)},Qs=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},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=Ys(t,n);let r=s(t),i=Zs(r);return Qs(Xs,r.href,()=>{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 t=document.createElement(`link`);if(t.rel=i?`stylesheet`:Js,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(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)})},$s=null,ec=null,tc=null,nc=0,rc=gr(),ic=/^(graph|flowchart|stateDiagram|sequenceDiagram|classDiagram|erDiagram|xychart)\b/;function ac(e){for(let t of e.split(`
|
|
79
|
-
`)){let e=t.trim();if(!(e===``||e.startsWith(`%%`)))return ic.test(e)}return!1}var oc={bg:`var(--fill)`,fg:`var(--ink)`,transparent:!0,font:`system-ui`};function sc(e){return e.replace(/@import url\([^)]*\);?/g,``)}async function cc(){return $s||=X(()=>import(`./dist-
|
|
79
|
+
`)){let e=t.trim();if(!(e===``||e.startsWith(`%%`)))return ic.test(e)}return!1}var oc={bg:`var(--fill)`,fg:`var(--ink)`,transparent:!0,font:`system-ui`};function sc(e){return e.replace(/@import url\([^)]*\);?/g,``)}async function cc(){return $s||=X(()=>import(`./dist-CmSi3yif.js`),[]),$s}function lc(){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 uc(){ec||=X(()=>import(`./mermaid.core-vlyR5lnz.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 ec,t=lc();return tc!==t&&(tc=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 dc(e){try{let t=await uc();await t.parse(e);let{svg:n}=await t.render(`diffo-mermaid-${++nc}`,e);return n}catch{return null}}async function fc(e){if(ac(e))try{return{svg:sc((await cc()).renderMermaidSVG(e,oc)),live:!0}}catch{}let t=await dc(e);return t===null?null:{svg:t,live:!1}}function pc(e){return rc.sanitize(e,{USE_PROFILES:{svg:!0,svgFilters:!0}})}var mc=.6;function hc(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*mc)}px`)}var gc=[29,29,31],_c=[245,245,247];function vc(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 yc(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 bc(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=vc(r)??vc(getComputedStyle(n).fill);if(!i||i.alpha<.5)continue;let a=yc(i.rgb),o=(a+.05)/(yc(gc)+.05)>=(yc(_c)+.05)/(a+.05)?gc:_c;for(let t of Array.from(e))t.setAttribute(`fill`,`rgb(${o.join(` `)})`)}}var xc=!1;function Sc(){if(xc)return;xc=!0;let e=()=>void Cc();new MutationObserver(e).observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]}),window.matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,e)}async function Cc(){if(lc()===tc)return;let e=document.querySelectorAll(`.mermaid-figure[data-mermaid-source]`);for(let t of Array.from(e)){let e=await dc(t.dataset.mermaidSource??``);e!==null&&t.isConnected&&(t.innerHTML=pc(e),hc(t))}}function wc(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 Tc(e){if(e&&wc(e).length!==0)for(let t of wc(e)){if(t.hasAttribute(`data-mermaid-done`))continue;t.setAttribute(`data-mermaid-done`,``);let e=t.textContent??``,n=await fc(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=pc(n.svg),hc(r),n.live||(r.dataset.mermaidSource=e,Sc()),t.replaceWith(r),n.live&&bc(r)}}function Ec(e){let t=Array.from(e.querySelectorAll(`tspan`));return t.length===0?e.textContent??``:t.map(e=>e.textContent??``).join(` `)}function Dc(e){return e.split(/[\s·,;()[\]{}"'«»]+/).filter(Boolean)}function Oc(e,t){for(let n of Dc(e)){let e=ms.exec(n);if(!e)continue;let r=gs(e[1],t);if(r!==null)return{path:r,line:e[2]===void 0?null:Number.parseInt(e[2],10)}}return null}function kc(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=Oc(Ec(e),t);n?(e.setAttribute(`data-diffo-jump`,ds(n.path,n.line)),e.setAttribute(`role`,`link`),e.setAttribute(`tabindex`,`0`),e.classList.add(`diffo-ref`)):e.setAttribute(`data-diffo-plain`,``)}}var Ac=(0,x.memo)(function({text:e,className:t,docPath:n,paths:r}){let i=(0,x.useRef)(null),a=n===void 0?pa(e):Ca(e,n);return(0,x.useEffect)(()=>{let e=i.current;if(!e)return;let t=async()=>{await Tc(e),r&&kc(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 jc({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)(W,{name:e===`you`?`user`:`sparkle`,size:`sm`})})}function Mc({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)(W,{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)(W,{name:`lock`,size:`sm`}),` Ask agent`]})]})}var Nc=[{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:["`","`"]}],Pc=[{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`}],Fc=[{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 Ic(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(`
|
|
80
80
|
`,i-1)+1,n=r.indexOf(`
|
|
81
81
|
`,a),o=n===-1?r.length:n,l=r.slice(e,o).split(`
|
|
82
82
|
`).map(e=>`${t.prefix}${e}`).join(`
|
|
83
83
|
`);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 Lc({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=Os(),[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,ee=d?u:A,I=d??j,L=(0,x.useRef)(null),te=P.trim().length>0,ne=e=>m?`> ${m.label}: ${m.text}\n\n${e}`:e,re=()=>{te&&(E===void 0?r(ne(P),y,ee):k?i(ne(P),y,void 0):r(ne(P),y,void 0,E))},R=()=>T(e=>e===`pr`?`agent`:`pr`),ie=()=>{N(e=>!e),v(`write`)},ae=(0,S.jsx)(S.Fragment,{children:n&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`span`,{className:`scope-chip`,children:[(0,S.jsx)(W,{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)(W,{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)(W,{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)(W,{name:`x`,size:`sm`})})]}),!y&&n.canWiden&&(0,S.jsx)(`button`,{type:`button`,className:`cbox-widen`,onClick:()=>b(!0),children:`+ whole changeset`})]})}),oe=(0,S.jsx)(`button`,{type:`button`,className:`cbox-close`,"data-tip":`Close (Esc)`,"aria-label":`Close`,onClick:a,children:(0,S.jsx)(W,{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)(Mc,{value:E,onChange:T}),(0,S.jsxs)(`span`,{className:`cbox-head-right`,children:[ae,oe]})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`cbox-title`,children:p===`agent`?`Ask your agent`:n?`Comment on`:e}),ae,oe]})}),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:Nc.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:()=>L.current&&Ic(L.current,e,F),children:(0,S.jsx)(W,{name:e.icon,size:`sm`})},t))}),(0,S.jsx)(`div`,{className:`cbox-body`,children:_===`write`?(0,S.jsx)(`textarea`,{ref:L,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(),R())}}):te?(0,S.jsx)(Ac,{className:`cbox-preview markdown`,text:P}):(0,S.jsx)(`div`,{className:`cbox-preview cbox-preview-empty`,children:`Nothing to preview yet.`})}),!te&&!D&&(0,S.jsx)(`div`,{className:`cbox-openers`,children:Pc.map(e=>(0,S.jsx)(`button`,{type:`button`,className:`cbox-opener`,title:e.text,onClick:()=>{F(e.text),I(e.intent),v(`write`),L.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:ie,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:Fc.map(({intent:e,label:t,title:n})=>(0,S.jsx)(`button`,{type:`button`,role:`radio`,className:`cbox-intent-chip`,"aria-checked":ee===e,title:n,onClick:()=>I(e),children:t},t))}),M&&(0,S.jsxs)(`span`,{className:`cbox-attach`,children:[(0,S.jsx)(W,{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:!te,onClick:()=>te&&i(ne(P),y,ee),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)(W,{name:`send`,size:`sm`}),` Send to agent`]}),(0,S.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,disabled:!te,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)(W,{name:`send`,size:`sm`}),D?`Add to review`:k?`Send to agent`:`Add comment`,(0,S.jsx)(`span`,{className:`btn-kbd`,children:`⌘↵`})]})]})]})]})}var Rc={fix:`Change`,question:`Question`},zc={open:`Draft`,sent:`Sent`,addressed:`Answered`,resolved:`Resolved`},Bc={open:`mute`,sent:`mute`,addressed:`ok`,resolved:`mute`};function Vc(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 Hc(e){return e<=1?`next in line`:`#${e} in line`}function Uc({working:e,place:t,unanswered:n,followUp:r,since:i}){let a=n?`no answer, the agent moved on`:e?`with the agent${i?` · ${wa(i)}`:``}`:r?`follow-up on the way${i?` · ${wa(i)}`:``}`:`queued, ${Hc(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)(jc,{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 Wc({code:e}){let[t,n]=(0,x.useState)(!1),r=e.split(`
|
|
84
84
|
`);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)(W,{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===``?`
|
|
85
|
-
`:e},`${t}-${e}`))})]})}function Gc(e,t){return e===`reviewer`||t===0?`commented`:`replied`}var Kc={APPROVED:`approved`,CHANGES_REQUESTED:`requested changes`,COMMENTED:`reviewed`,DISMISSED:`dismissed`};function qc(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 Yc({text:e,links:t}){return t?(0,S.jsx)(`div`,{onClick:e=>{let n=hs(e.target);n&&(e.preventDefault(),t.onJump(n.path,n.line))},children:(0,S.jsx)(Ac,{className:`cmt-body markdown`,text:_s(e,t.paths),paths:t.paths})}):(0,S.jsx)(Ac,{className:`cmt-body markdown`,text:e})}function Xc({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)(W,{name:`chev`,size:`sm`})}),(0,S.jsx)(W,{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)(Ac,{className:`psc-body markdown`,text:l.text})]})}return n?(0,S.jsx)(`div`,{className:`psc psc-editing`,children:(0,S.jsx)(Lc,{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)(W,{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)(Ac,{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)(W,{name:`x`,size:`sm`})})]})]})}function Zc({thread:e,actions:t,showContext:n=!1,agentConnected:r=!1,working:i=!1,queuePosition:a,gone:o=!1,links:s,asides:c}){let l=Os(),u=U(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),[ee,I]=(0,x.useState)(null),L=(0,x.useRef)(null),te=(0,x.useRef)(null),ne=(0,x.useRef)(void 0);(0,x.useEffect)(()=>()=>clearTimeout(ne.current),[]);let re=(n=!0)=>{v.trim()&&(D(!1),t.reply(e.id,v,n).then(()=>y(``)).catch(()=>D(!0)))},R=P?e.messages.findIndex(e=>e.id===P.id):-1,ie=R===-1?0:e.messages.length-1-R,ae=R!==-1&&ut(e,R),oe=ae&&r&&(e.state===`sent`||e.state===`addressed`),se=n=>t.edit!==void 0&&n.author===`reviewer`&&e.state!==`resolved`&&n.github===void 0,ce=e=>{I(null),F({id:e.id,draft:e.text})},le=()=>{F(null),I(null)},ue=(n=!0)=>{if(!P||R===-1)return;let r=P.draft.trim();if(r){if(r===e.messages[R].text.trim())return le();I(null),t.edit(e.id,P.id,r,n).then(le).catch(e=>I(e instanceof Error&&e.message?e.message:`couldn't reach the diffo server — your text is still here; try again`))}},de=()=>(D(!1),T(null),t.send(e.id).then(({delivered:e,copied:t,prompt:n})=>{e||(t?(C(!0),clearTimeout(ne.current),ne.current=setTimeout(()=>C(!1),2500)):T(n??null))}).catch(()=>D(!0))),z=ot(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=As(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=dt(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===``,Oe=()=>{Ee!==null&&(y(Ee),k(!0),requestAnimationFrame(()=>{let e=te.current;e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))}))},V=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?Ms.note:e.state===`addressed`&&e.intent===`fix`?`Addressed`:zc[e.state],Ae=u?f?`attn`:e.state===`resolved`?`mute`:`pr`:be||he?`attn`:Bc[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&&!lt(e)&&(0,S.jsx)(`span`,{className:`thread-badge thread-badge-kind thread-kind-${e.intent}`,children:Rc[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)(W,{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)(W,{name:`link`,size:`sm`}),` GitHub`]}),e.codeChanged&&(0,S.jsxs)(`span`,{className:`thread-badge`,children:[(0,S.jsx)(W,{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&<(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)(Uc,{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=ie>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(qc(e)),children:[(0,S.jsx)(W,{name:`globe`,size:`sm`}),` Post as PR comment`]}),Ve=m!==null&&(0,S.jsx)(`div`,{className:`thread-aside-compose`,children:(0,S.jsx)(Lc,{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:de,children:[(0,S.jsx)(W,{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:de,title:r?`send this thread to your agent`:`mark sent and copy the prompt`,children:[(0,S.jsx)(W,{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)(W,{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:L,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:Ls(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)(W,{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:L,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)(W,{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)(W,{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:Qc(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:Ls(e.messages[0]?.text??``)}):(0,S.jsxs)(S.Fragment,{children:[n&&e.codeContext&&(0,S.jsx)(Wc,{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===R?` thread-message-editing`:``}${R!==-1&&a>R?` thread-message-cut`:``}`,children:[(0,S.jsxs)(`div`,{className:`cmt-head`,children:[(0,S.jsx)(jc,{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 ${Vc(n.durationMs)}`:`${Gc(n.author,a)} ${wa(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`})]}),se(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||ce(n)},children:(0,S.jsx)(W,{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(),le()):Jc(e,()=>ue(!0))}}),ee&&(0,S.jsx)(`div`,{className:`cmt-edit-error`,role:`alert`,children:ee}),(0,S.jsxs)(`div`,{className:`cmt-edit-foot`,children:[(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:le,children:`Cancel`}),oe&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>ue(!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:()=>ue(!0),title:oe?`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`:ae?`save the edit — the thread waits for the agent, which is told its earlier replies were withdrawn`:`save the edit`,children:[oe?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(W,{name:`send`,size:`sm`}),` Save & resend`]}):`Save`,(0,S.jsx)(`span`,{className:`btn-kbd`,children:`⌘↵`})]})]})]}):(0,S.jsx)(Yc,{text:n.text,links:s}),n.author===`agent`&&n.prComment&&(0,S.jsx)(Xc,{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===R&&ie>0&&(0,S.jsx)(`div`,{className:`cmt-cut`,role:`note`,children:(0,S.jsxs)(`span`,{children:[`Saving removes the ${ie===1?`message`:`${ie} messages`} below`,ae&&` · 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&&R===-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)(W,{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:Oe,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)(W,{name:`sparkle`,size:`sm`,className:`thread-offer-icon thread-ghost-icon`}),(0,S.jsx)(`textarea`,{autoFocus:!0,ref:te,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=>{V(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:Oe,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)(W,{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 Qc(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`||U(e)&&n.kind===`changeset`)return`Comment on the pull request`;let i=lt(e)?`Agent comment`:e.messages[0]?.author===`github`?`${e.messages[0].github?.user.login??`GitHub`}'s comment`:U(e)?`Review comment`:`Comment`;return n.kind===`changeset`?lt(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}:${ht(n)}`:n.path:n.kind===`hunk`?`${i} on ${n.endLine===void 0?`line`:`lines`} ${ht(n)}`:`${i} on this file`}function $c({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)(Zc,{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 el({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)(tl,{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)(rl,{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)(rl,{item:e,onOpen:n},e.thread.id))})]})]})})}function tl({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 nl(e){if(e.working)return{label:`working on it`,kind:`now`};if(e.queued!==void 0)return{label:Hc(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 rl({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}=nl(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:[Vc(o),`…`]}),e.durationMs!==void 0&&!e.working&&(0,S.jsx)(`span`,{className:`monitor-took`,children:Vc(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 il({status:e,onSetEnabled:t,onClose:n}){let[r,i]=(0,x.useState)(!1),a=e.source===`env`;return(0,S.jsxs)(Ft,{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 al=[/(^|\/)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 ol(e){let t=0;for(let n of e.hunks)for(let e of n.lines)e.kind!==`context`&&t++;return t}function sl(e){return e.hunks.length===0?null:al.some(t=>t.test(e.path))?`generated`:ol(e)>400?`large`:null}var cl={fromTop:0,fromBottom:0};function ll(e){return e.lines.filter(e=>e.kind!==`del`).length}function ul(e){return e.lines.filter(e=>e.kind!==`add`).length}function dl(e){return ll(e)===0?e.newStart+1:e.newStart}function fl(e){return ul(e)===0?e.oldStart+1:e.oldStart}function pl(e){return dl(e)}function ml(e){return dl(e)+ll(e)-1}function hl(e){return dl(e)-fl(e)}function gl(e){return dl(e)+ll(e)-(fl(e)+ul(e))}function _l(e){let t=e.hunks;if(t.length===0)return[];let n=[],r=t[0];pl(r)>1&&n.push({key:`top:${r.id}`,above:null,below:0,startNewNo:1,endNewNo:pl(r)-1,offset:hl(r)});for(let e=1;e<t.length;e++){let r=t[e-1],i=t[e],a=ml(r)+1,o=pl(i)-1;o>=a&&n.push({key:`${r.id}:${i.id}`,above:e-1,below:e,startNewNo:a,endNewNo:o,offset:hl(i)})}let i=t[t.length-1],a=e.newLineCount;return typeof a==`number`&&a>ml(i)&&n.push({key:`${i.id}:tail`,above:t.length-1,below:null,startNewNo:ml(i)+1,endNewNo:a,offset:gl(i)}),n}function vl(e){return e.endNewNo-e.startNewNo+1}function yl(e,t){return Math.max(0,vl(e)-t.fromTop-t.fromBottom)}function bl(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 xl(e,t,n){if(yl(t,n)===0){let n=bl(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?bl(e,t,t.startNewNo,t.startNewNo+n.fromTop-1):[],bottom:n.fromBottom>0?bl(e,t,t.endNewNo-n.fromBottom+1,t.endNewNo):[],merged:!1}}var Sl={freshHunkIds:new Set,changedViewedHunkIds:new Set};function Cl(e,t,n){if(!e)return Sl;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 wl({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)(El,{resolved:e,open:t===a,onToggle:()=>n(t===a?null:a),onJump:r,onComment:i?()=>i(a):void 0},a))]})}function Tl(e){return e.line===void 0?e.path:`${e.path}:${e.line}${e.endLine===void 0?``:`–${e.endLine}`}`}function El({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)(W,{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)(Ac,{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:Tl(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}`]})]},Tl(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 Dl={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:`cpp`,cc:`cpp`,cpp:`cpp`,cxx:`cpp`,hh:`cpp`,hpp:`cpp`,hxx:`cpp`,m:`objective-c`,mm:`objective-cpp`,proto:`proto`,gn:`gn`,gni:`gn`,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`},Ol={c:()=>X(()=>import(`./c-Cz4nF6n_.js`),__vite__mapDeps([19,20])),cpp:()=>X(()=>import(`./cpp-DzjeI0uH.js`),__vite__mapDeps([21,22,20])),csharp:()=>X(()=>import(`./csharp-dmMxLVLW.js`),[]),css:()=>X(()=>import(`./css-DgaLhXQH.js`),__vite__mapDeps([23,24])),docker:()=>X(()=>import(`./docker-IyjqRm3v.js`),[]),gn:()=>X(()=>import(`./gn-CAXYAgV-.js`),[]),go:()=>X(()=>import(`./go-rLFTqkRN.js`),[]),html:()=>X(()=>import(`./html-BWDvXlHg.js`),__vite__mapDeps([25,26,24,27])),java:()=>X(()=>import(`./java-_ATy9zCa.js`),__vite__mapDeps([28,29])),javascript:()=>X(()=>import(`./javascript-CpIGwZ_Y.js`),__vite__mapDeps([30,27])),json:()=>X(()=>import(`./json-C3WlssX3.js`),__vite__mapDeps([31,32])),jsx:()=>X(()=>import(`./jsx-C4yDKi0A.js`),__vite__mapDeps([33,34])),kotlin:()=>X(()=>import(`./kotlin-DhhofPvG.js`),[]),markdown:()=>X(()=>import(`./markdown-BYOwaDjH.js`),[]),"objective-c":()=>X(()=>import(`./objective-c-D1A_Heim.js`),[]),"objective-cpp":()=>X(()=>import(`./objective-cpp-BsSzOQcm.js`),[]),php:()=>X(()=>import(`./php-CUj1wjLQ.js`),__vite__mapDeps([35,24,27,26,32,36,29,37])),proto:()=>X(()=>import(`./proto-DB4EqR-F.js`),[]),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-CVTB3cr6.js`),__vite__mapDeps([44,41])),sql:()=>X(()=>import(`./sql-CfM2IJm3.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-CGosfAUg.js`),__vite__mapDeps([47,40])),typescript:()=>X(()=>import(`./typescript-Bb1J8qyy.js`),__vite__mapDeps([48,39])),vue:()=>X(()=>import(`./vue-rALd9gPk.js`),__vite__mapDeps([49,24,27,26,32,39])),xml:()=>X(()=>import(`./xml-DuKfbPI6.js`),__vite__mapDeps([50,36,29])),yaml:()=>X(()=>import(`./yaml-DDA_XMNu.js`),__vite__mapDeps([51,42]))};function kl(e){let t=e.slice(e.lastIndexOf(`/`)+1).toLowerCase();return t===`dockerfile`?`docker`:Dl[t.slice(t.lastIndexOf(`.`)+1)]??null}var Al=null;async function jl(){return Al||=(async()=>{let[{createHighlighterCore:e},{createOnigurumaEngine:t}]=await Promise.all([X(()=>import(`./core-DmmPKspM.js`),[]),X(()=>import(`./engine-oniguruma-MxRvz1no.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`),[]))})})(),Al}var Ml=new Map;function Nl(e,t){if(e.getLoadedLanguages().includes(t))return null;let n=Ml.get(t);if(n)return n;let r=Ol[t];if(!r)return null;let i=r().then(t=>e.loadLanguage(t.default)).finally(()=>Ml.delete(t));return Ml.set(t,i),i}async function Pl(e,t,n){let r=kl(t);if(!r||e.length===0)return null;try{let t=await jl();return await Nl(t,r),t.getLoadedLanguages().includes(r)?t.codeToTokensBase(e.join(`
|
|
85
|
+
`:e},`${t}-${e}`))})]})}function Gc(e,t){return e===`reviewer`||t===0?`commented`:`replied`}var Kc={APPROVED:`approved`,CHANGES_REQUESTED:`requested changes`,COMMENTED:`reviewed`,DISMISSED:`dismissed`};function qc(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 Yc({text:e,links:t}){return t?(0,S.jsx)(`div`,{onClick:e=>{let n=hs(e.target);n&&(e.preventDefault(),t.onJump(n.path,n.line))},children:(0,S.jsx)(Ac,{className:`cmt-body markdown`,text:_s(e,t.paths),paths:t.paths})}):(0,S.jsx)(Ac,{className:`cmt-body markdown`,text:e})}function Xc({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)(W,{name:`chev`,size:`sm`})}),(0,S.jsx)(W,{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)(Ac,{className:`psc-body markdown`,text:l.text})]})}return n?(0,S.jsx)(`div`,{className:`psc psc-editing`,children:(0,S.jsx)(Lc,{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)(W,{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)(Ac,{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)(W,{name:`x`,size:`sm`})})]})]})}function Zc({thread:e,actions:t,showContext:n=!1,agentConnected:r=!1,working:i=!1,queuePosition:a,gone:o=!1,links:s,asides:c}){let l=Os(),u=U(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),[ee,I]=(0,x.useState)(null),L=(0,x.useRef)(null),te=(0,x.useRef)(null),ne=(0,x.useRef)(void 0);(0,x.useEffect)(()=>()=>clearTimeout(ne.current),[]);let re=(n=!0)=>{v.trim()&&(D(!1),t.reply(e.id,v,n).then(()=>y(``)).catch(()=>D(!0)))},R=P?e.messages.findIndex(e=>e.id===P.id):-1,ie=R===-1?0:e.messages.length-1-R,ae=R!==-1&&ut(e,R),oe=ae&&r&&(e.state===`sent`||e.state===`addressed`),se=n=>t.edit!==void 0&&n.author===`reviewer`&&e.state!==`resolved`&&n.github===void 0,ce=e=>{I(null),F({id:e.id,draft:e.text})},le=()=>{F(null),I(null)},ue=(n=!0)=>{if(!P||R===-1)return;let r=P.draft.trim();if(r){if(r===e.messages[R].text.trim())return le();I(null),t.edit(e.id,P.id,r,n).then(le).catch(e=>I(e instanceof Error&&e.message?e.message:`couldn't reach the diffo server — your text is still here; try again`))}},de=()=>(D(!1),T(null),t.send(e.id).then(({delivered:e,copied:t,prompt:n})=>{e||(t?(C(!0),clearTimeout(ne.current),ne.current=setTimeout(()=>C(!1),2500)):T(n??null))}).catch(()=>D(!0))),z=ot(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=As(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=dt(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===``,Oe=()=>{Ee!==null&&(y(Ee),k(!0),requestAnimationFrame(()=>{let e=te.current;e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))}))},V=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?Ms.note:e.state===`addressed`&&e.intent===`fix`?`Addressed`:zc[e.state],Ae=u?f?`attn`:e.state===`resolved`?`mute`:`pr`:be||he?`attn`:Bc[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&&!lt(e)&&(0,S.jsx)(`span`,{className:`thread-badge thread-badge-kind thread-kind-${e.intent}`,children:Rc[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)(W,{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)(W,{name:`link`,size:`sm`}),` GitHub`]}),e.codeChanged&&(0,S.jsxs)(`span`,{className:`thread-badge`,children:[(0,S.jsx)(W,{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&<(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)(Uc,{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=ie>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(qc(e)),children:[(0,S.jsx)(W,{name:`globe`,size:`sm`}),` Post as PR comment`]}),Ve=m!==null&&(0,S.jsx)(`div`,{className:`thread-aside-compose`,children:(0,S.jsx)(Lc,{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:de,children:[(0,S.jsx)(W,{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:de,title:r?`send this thread to your agent`:`mark sent and copy the prompt`,children:[(0,S.jsx)(W,{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)(W,{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:L,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:Ls(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)(W,{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:L,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)(W,{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)(W,{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:Qc(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:Ls(e.messages[0]?.text??``)}):(0,S.jsxs)(S.Fragment,{children:[n&&e.codeContext&&(0,S.jsx)(Wc,{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===R?` thread-message-editing`:``}${R!==-1&&a>R?` thread-message-cut`:``}`,children:[(0,S.jsxs)(`div`,{className:`cmt-head`,children:[(0,S.jsx)(jc,{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 ${Vc(n.durationMs)}`:`${Gc(n.author,a)} ${wa(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`})]}),se(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||ce(n)},children:(0,S.jsx)(W,{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(),le()):Jc(e,()=>ue(!0))}}),ee&&(0,S.jsx)(`div`,{className:`cmt-edit-error`,role:`alert`,children:ee}),(0,S.jsxs)(`div`,{className:`cmt-edit-foot`,children:[(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:le,children:`Cancel`}),oe&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>ue(!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:()=>ue(!0),title:oe?`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`:ae?`save the edit — the thread waits for the agent, which is told its earlier replies were withdrawn`:`save the edit`,children:[oe?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(W,{name:`send`,size:`sm`}),` Save & resend`]}):`Save`,(0,S.jsx)(`span`,{className:`btn-kbd`,children:`⌘↵`})]})]})]}):(0,S.jsx)(Yc,{text:n.text,links:s}),n.author===`agent`&&n.prComment&&(0,S.jsx)(Xc,{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===R&&ie>0&&(0,S.jsx)(`div`,{className:`cmt-cut`,role:`note`,children:(0,S.jsxs)(`span`,{children:[`Saving removes the ${ie===1?`message`:`${ie} messages`} below`,ae&&` · 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&&R===-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)(W,{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:Oe,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)(W,{name:`sparkle`,size:`sm`,className:`thread-offer-icon thread-ghost-icon`}),(0,S.jsx)(`textarea`,{autoFocus:!0,ref:te,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=>{V(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:Oe,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)(W,{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 Qc(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`||U(e)&&n.kind===`changeset`)return`Comment on the pull request`;let i=lt(e)?`Agent comment`:e.messages[0]?.author===`github`?`${e.messages[0].github?.user.login??`GitHub`}'s comment`:U(e)?`Review comment`:`Comment`;return n.kind===`changeset`?lt(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}:${ht(n)}`:n.path:n.kind===`hunk`?`${i} on ${n.endLine===void 0?`line`:`lines`} ${ht(n)}`:`${i} on this file`}function $c({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)(Zc,{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 el({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)(tl,{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)(rl,{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)(rl,{item:e,onOpen:n},e.thread.id))})]})]})})}function tl({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 nl(e){if(e.working)return{label:`working on it`,kind:`now`};if(e.queued!==void 0)return{label:Hc(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 rl({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}=nl(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:[Vc(o),`…`]}),e.durationMs!==void 0&&!e.working&&(0,S.jsx)(`span`,{className:`monitor-took`,children:Vc(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 il({status:e,onSetEnabled:t,onClose:n}){let[r,i]=(0,x.useState)(!1),a=e.source===`env`;return(0,S.jsxs)(Ft,{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 al=[/(^|\/)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 ol(e){let t=0;for(let n of e.hunks)for(let e of n.lines)e.kind!==`context`&&t++;return t}function sl(e){return e.hunks.length===0?null:al.some(t=>t.test(e.path))?`generated`:ol(e)>400?`large`:null}var cl={fromTop:0,fromBottom:0};function ll(e){return e.lines.filter(e=>e.kind!==`del`).length}function ul(e){return e.lines.filter(e=>e.kind!==`add`).length}function dl(e){return ll(e)===0?e.newStart+1:e.newStart}function fl(e){return ul(e)===0?e.oldStart+1:e.oldStart}function pl(e){return dl(e)}function ml(e){return dl(e)+ll(e)-1}function hl(e){return dl(e)-fl(e)}function gl(e){return dl(e)+ll(e)-(fl(e)+ul(e))}function _l(e){let t=e.hunks;if(t.length===0)return[];let n=[],r=t[0];pl(r)>1&&n.push({key:`top:${r.id}`,above:null,below:0,startNewNo:1,endNewNo:pl(r)-1,offset:hl(r)});for(let e=1;e<t.length;e++){let r=t[e-1],i=t[e],a=ml(r)+1,o=pl(i)-1;o>=a&&n.push({key:`${r.id}:${i.id}`,above:e-1,below:e,startNewNo:a,endNewNo:o,offset:hl(i)})}let i=t[t.length-1],a=e.newLineCount;return typeof a==`number`&&a>ml(i)&&n.push({key:`${i.id}:tail`,above:t.length-1,below:null,startNewNo:ml(i)+1,endNewNo:a,offset:gl(i)}),n}function vl(e){return e.endNewNo-e.startNewNo+1}function yl(e,t){return Math.max(0,vl(e)-t.fromTop-t.fromBottom)}function bl(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 xl(e,t,n){if(yl(t,n)===0){let n=bl(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?bl(e,t,t.startNewNo,t.startNewNo+n.fromTop-1):[],bottom:n.fromBottom>0?bl(e,t,t.endNewNo-n.fromBottom+1,t.endNewNo):[],merged:!1}}var Sl={freshHunkIds:new Set,changedViewedHunkIds:new Set};function Cl(e,t,n){if(!e)return Sl;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 wl({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)(El,{resolved:e,open:t===a,onToggle:()=>n(t===a?null:a),onJump:r,onComment:i?()=>i(a):void 0},a))]})}function Tl(e){return e.line===void 0?e.path:`${e.path}:${e.line}${e.endLine===void 0?``:`–${e.endLine}`}`}function El({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)(W,{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)(Ac,{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:Tl(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}`]})]},Tl(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 Dl={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:`cpp`,cc:`cpp`,cpp:`cpp`,cxx:`cpp`,hh:`cpp`,hpp:`cpp`,hxx:`cpp`,m:`objective-c`,mm:`objective-cpp`,proto:`proto`,gn:`gn`,gni:`gn`,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`},Ol={c:()=>X(()=>import(`./c-Cz4nF6n_.js`),__vite__mapDeps([19,20])),cpp:()=>X(()=>import(`./cpp-DzjeI0uH.js`),__vite__mapDeps([21,22,20])),csharp:()=>X(()=>import(`./csharp-dmMxLVLW.js`),[]),css:()=>X(()=>import(`./css-DgaLhXQH.js`),__vite__mapDeps([23,24])),docker:()=>X(()=>import(`./docker-IyjqRm3v.js`),[]),gn:()=>X(()=>import(`./gn-CAXYAgV-.js`),[]),go:()=>X(()=>import(`./go-rLFTqkRN.js`),[]),html:()=>X(()=>import(`./html-BWDvXlHg.js`),__vite__mapDeps([25,26,24,27])),java:()=>X(()=>import(`./java-_ATy9zCa.js`),__vite__mapDeps([28,29])),javascript:()=>X(()=>import(`./javascript-CpIGwZ_Y.js`),__vite__mapDeps([30,27])),json:()=>X(()=>import(`./json-C3WlssX3.js`),__vite__mapDeps([31,32])),jsx:()=>X(()=>import(`./jsx-C4yDKi0A.js`),__vite__mapDeps([33,34])),kotlin:()=>X(()=>import(`./kotlin-DhhofPvG.js`),[]),markdown:()=>X(()=>import(`./markdown-BYOwaDjH.js`),[]),"objective-c":()=>X(()=>import(`./objective-c-D1A_Heim.js`),[]),"objective-cpp":()=>X(()=>import(`./objective-cpp-BsSzOQcm.js`),[]),php:()=>X(()=>import(`./php-CUj1wjLQ.js`),__vite__mapDeps([35,24,27,26,32,36,29,37])),proto:()=>X(()=>import(`./proto-DB4EqR-F.js`),[]),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-CVTB3cr6.js`),__vite__mapDeps([44,41])),sql:()=>X(()=>import(`./sql-CfM2IJm3.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-CGosfAUg.js`),__vite__mapDeps([47,40])),typescript:()=>X(()=>import(`./typescript-Bb1J8qyy.js`),__vite__mapDeps([48,39])),vue:()=>X(()=>import(`./vue-rALd9gPk.js`),__vite__mapDeps([49,24,27,26,32,39])),xml:()=>X(()=>import(`./xml-DuKfbPI6.js`),__vite__mapDeps([50,36,29])),yaml:()=>X(()=>import(`./yaml-DDA_XMNu.js`),__vite__mapDeps([51,42]))};function kl(e){let t=e.slice(e.lastIndexOf(`/`)+1).toLowerCase();return t===`dockerfile`?`docker`:Dl[t.slice(t.lastIndexOf(`.`)+1)]??null}var Al=null;async function jl(){return Al||=(async()=>{let[{createHighlighterCore:e},{createOnigurumaEngine:t}]=await Promise.all([X(()=>import(`./core-ocswKbjM.js`),[]),X(()=>import(`./engine-oniguruma-BZHOTLBc.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`),[]))})})(),Al}var Ml=new Map;function Nl(e,t){if(e.getLoadedLanguages().includes(t))return null;let n=Ml.get(t);if(n)return n;let r=Ol[t];if(!r)return null;let i=r().then(t=>e.loadLanguage(t.default)).finally(()=>Ml.delete(t));return Ml.set(t,i),i}async function Pl(e,t,n){let r=kl(t);if(!r||e.length===0)return null;try{let t=await jl();return await Nl(t,r),t.getLoadedLanguages().includes(r)?t.codeToTokensBase(e.join(`
|
|
86
86
|
`),{lang:r,theme:n?`github-dark`:`github-light`,includeExplanation:`scopeName`}):null}catch{return null}}var Fl=/^(text|comment|string|keyword|storage|punctuation|constant\.(numeric|language|character)|variable\.language|support\.type\.primitive)\b/;function Il(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=>Fl.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 Ll=400,Rl=.3,zl=400,Bl=3,Vl=.65;function Hl(e){return e.match(/[A-Za-z0-9_$]+|\s+|[^A-Za-z0-9_$\s]/g)??[]}function Ul(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 Wl(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 Gl(e){let t=[];for(let n of e){let e=t[t.length-1];e&&n.start-e.end<=Bl?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 ql(e,t){if(e.length>Ll||t.length>Ll)return null;let n=Hl(e),r=Hl(t);if(n.length===0||r.length===0)return null;let i=Ul(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<Rl)return null;let l=Gl(Wl(n,a)),u=Gl(Wl(r,o));return Kl(l,e.length)>Vl||Kl(u,t.length)>Vl?{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=ql(e[t[i]].text,e[n[i]].text);a&&r.push([t[i],n[i],a])}return r}if(t.length*n.length>zl)return r;let i=[];for(let r of t)for(let t of n){let n=ql(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 Yl(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 Xl(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 Zl(e,t){for(let n of e){let e=n.hunks.find(e=>e.id===t);if(e)return e}}function Ql(e,t,n){return e.findIndex(e=>t===`old`?e.kind!==`add`&&e.oldNo===n:e.kind!==`del`&&e.newNo===n)}function $l(e,t,n){let r=Zl(t,e.hunkId),i=Zl(n,e.hunkId);if(!r||!i||r===i||r.lines.length!==i.lines.length||r.lines.some((e,t)=>e.kind!==i.lines[t].kind))return e;let a=t=>{let n=Ql(r.lines,e.side,t);if(n===-1)return null;let a=i.lines[n];return e.side===`old`?a.oldNo:a.newNo},o=a(e.line);if(o===null)return e;if(e.endLine===void 0)return o===e.line?e:{...e,line:o};let s=a(e.endLine);return s===null?{...e,line:o}:{...e,line:o,endLine:s}}function eu(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=t.commit===void 0?tu(e,t):null;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 tu(e,t){let n=e.find(e=>e.path===t.path);return n?n.hunks.find(e=>ou(e.lines,t)!==-1)?.id??null:null}function nu(e,t,n){let r=new Set(e.map(e=>e.path)),i=[];for(let a of n){let n=a.anchor;n.kind===`changeset`?i.push(a):n.kind===`file`?r.has(n.path)&&i.push(a):n.kind===`hunk`&&r.has(n.path)&&i.push({...a,anchor:$l(n,t,e)})}return eu(e,i)}function ru(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 iu(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 au(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=iu(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 ou(e,t){return Ql(e,t.side,t.line)}function su(e,t){if(t.endLine!==void 0){let n=Ql(e,t.side,t.endLine);if(n!==-1)return n}return ou(e,t)}function cu(e,t){let n=new Map;for(let r of t){if(r.anchor.kind!==`hunk`)continue;let t=su(e,r.anchor),i=n.get(t);i?i.push(r):n.set(t,[r])}return n}function lu(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=ou(e,t),a=su(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 uu(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=ou(e,t),a=su(e,t);i!==-1&&a!==-1&&n.add(Math.min(i,a))}return n}function du(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 fu({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)(W,{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)(W,{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)(W,{name:`up`,size:n?`xs`:`sm`})})]})}function pu({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)(W,{name:`fold`,size:`sm`})})}var mu=`couldn't read more context; the file may have changed since`;function hu({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)(fu,{gap:e}),(e.merged||e.expanded)&&(0,S.jsx)(pu,{onCollapse:e.onCollapse}),e.failed&&(0,S.jsx)(`span`,{className:`hunk-expand-failed`,role:`status`,children:mu})]})})})})})})}function gu(e,t){let n=Oa(),[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([Pl(a.map(e=>e.text),t,n),Pl(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 _u({line:e,tokens:t,ranges:n}){if(!t)return(0,S.jsx)(S.Fragment,{children:Xl(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 Il(e).map((e,a)=>{let o=r;r+=e.content.length;let s=e.sym?void 0:`nosym`,c=Xl(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 vu={add:`+`,del:`−`,context:` `};function yu(e,t){return{"data-side":t,"data-old":e.oldNo??void 0,"data-new":e.newNo??void 0}}function bu(){return(0,S.jsx)(`span`,{className:`line-range-glyph`,"aria-hidden":`true`,children:(0,S.jsx)(W,{name:`chat`,size:`sm`})})}function xu(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 Su(e,t){if(e)return n=>{n.button===0&&(n.preventDefault(),e(t,n.shiftKey))}}function Cu({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)(W,{name:`plus`,size:`sm`})})}function wu({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=Su(c,p);return(0,S.jsxs)(x.Fragment,{children:[(0,S.jsxs)(`tr`,{className:`line line-${e.kind}${xu(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)(bu,{}),a&&(0,S.jsx)(Cu,{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:vu[e.kind]}),(0,S.jsx)(`td`,{className:`line-code`,...yu(e,e.kind===`del`?`base`:`head`),children:(0,S.jsx)(_u,{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 Tu({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=du(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${xu(u,d,s,e.left?.idx,e.right?.idx)}`,children:[(0,S.jsxs)(`td`,{className:`line-no`,onMouseDown:e.left?Su(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)(bu,{}),a&&e.left&&(0,S.jsx)(Cu,{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&&yu(e.left.line,`base`),onMouseEnter:g(e.left?.idx),onClick:h(e.left?.idx),children:e.left&&(0,S.jsx)(_u,{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?Su(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)(bu,{}),a&&e.right&&(0,S.jsx)(Cu,{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&&yu(e.right.line,`head`),onMouseEnter:g(e.right?.idx),onClick:h(e.right?.idx),children:e.right&&(0,S.jsx)(_u,{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 Eu({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=gu(E,e.path),O=(0,x.useMemo)(()=>Yl(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)=>{t&&v?y({at:v.at,edge:e}):C({start:e,end:e})}:void 0,F=b?e=>C(t=>t&&t.end!==e?{...t,end:e}:t):void 0,ee=cu(E,d),I=ee.get(-1)??[],L=(0,x.useMemo)(()=>lu(E,d),[E,d]),te=(0,x.useMemo)(()=>uu(E,d),[E,d]),[ne,re]=(0,x.useState)(null),R=(0,x.useMemo)(()=>{let e=b??(v?{start:v.at,end:v.edge}:null),t=new Set(ne?.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,ne]),ie=t=>{if(!f)return null;let n=au(e.id,e.path,E,t.at,t.edge);if(!n)return null;let r=`${e.path.slice(e.path.lastIndexOf(`/`)+1)}:${ht(n)}`,i=e=>e?{kind:`changeset`}:n;return(0,S.jsx)(Lc,{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})},ae=e=>{let t=ee.get(e);return!t||lu(E,t).size===0?``:` thread-row-ranged${ne?.idx===e?` thread-row-lit`:``}`},oe=e=>{let t=ee.get(e),n=v!==null&&Math.max(v.at,v.edge)===e?ie(v):null;if(!t&&!n)return null;let r=t?lu(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)($c,{threads:t,actions:f,agentConnected:p,workingOn:m,queuedOn:h})}),n]})},se=n&&!i,ce=[`hunk`];se&&ce.push(`hunk-since-review`),t&&ce.push(`hunk-fresh`),i&&ce.push(`hunk-viewed`),a&&ce.push(`hunk-selected`);let le=e.lines.filter(e=>e.kind!==`add`).length,ue=e.lines.filter(e=>e.kind!==`del`).length,de=u?.merged??!1,z=!se&&r&&(0,S.jsx)(`span`,{className:`hunk-badge`,children:`changed since you read it`}),B=(0,S.jsx)(`tr`,{className:`hunk-boundary${de?` hunk-boundary-merged`:``}`,title:se?`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&&!de&&(0,S.jsx)(fu,{gap:u}),u&&(de||u.expanded)&&(0,S.jsx)(pu,{onCollapse:u.onCollapse}),!de&&(0,S.jsxs)(`span`,{className:`hunk-at`,title:`hunk position in the file`,children:[`@@ −`,e.oldStart,`,`,le,` +`,e.newStart,`,`,ue,` @@`,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:mu}),z]})})});return(0,S.jsxs)(`div`,{className:ce.join(` `),"data-hunk-id":e.id,onClick:()=>o?.(e.id),children:[s===`split`?(0,S.jsx)(Tu,{lines:E,tokens:D,ranges:O,extraFor:oe,extraClass:ae,onComment:f?e=>y({at:e,edge:e}):void 0,onRowClick:f?T:void 0,focusRow:w,onGutterDown:P,onLineEnter:F,selRows:R,rangeRows:L,rangeStarts:te,boundary:B}):(0,S.jsx)(wu,{lines:E,tokens:D,ranges:O,extraFor:oe,extraClass:ae,onComment:f?e=>y({at:e,edge:e}):void 0,onRowClick:f?T:void 0,focusRow:w,onGutterDown:P,onLineEnter:F,selRows:R,rangeRows:L,rangeStarts:te,boundary:B}),I.length>0&&f&&(0,S.jsx)($c,{threads:I,actions:f,agentConnected:p,workingOn:m,queuedOn:h})]})}function Du(e,t){return`/api/file?path=${encodeURIComponent(e)}&side=${t}`}function Ou({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:Du(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:Du(e.path,`head`),alt:`${e.path} (head)`}),(0,S.jsx)(`figcaption`,{children:`head`})]})]})}function ku(e){return e.status!==`deleted`&&/\.(md|markdown)$/i.test(e.path)}function Au({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)(Ft,{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)(Ac,{className:`markdown md-doc`,text:n,docPath:e})})}function ju({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)(W,{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 ${w.noun??`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)(W,{name:`search`,size:`sm`}),(0,S.jsx)(`span`,{className:`pane-q-word`,children:M}),(0,S.jsx)(W,{name:`x`,size:`sm`})]}),!w&&k&&(0,S.jsx)(Mu,{on:h,onChange:g,label:_>0?`Only ${_} since review`:`Only since review`,onLabel:_>0?`only ${_} since review`:void 0}),!w&&A&&(0,S.jsx)(Mu,{on:u,onChange:d,label:T>0?`Hide ${T} reviewed`:`Hide reviewed`,onLabel:T>0?`${T} reviewed hidden`:void 0}),O&&(0,S.jsx)(Mu,{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)(W,{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)(W,{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)(W,{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 ${w.noun??`layer`}: ${w.prev.title} ([)`,"aria-label":`Previous ${w.noun??`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 ${w.noun??`layer`}: ${w.next.title} (])`,"aria-label":`Next ${w.noun??`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 Mu({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 Nu=e=>e.toLocaleString(`en-US`);function Pu({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?Nu(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:[`+`,Nu(i.additions)]}),i.deletions>0&&(0,S.jsxs)(`span`,{className:`stat-del`,children:[`−`,Nu(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)(W,{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)(W,{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)(Iu,{}),(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)(W,{name:`x`,size:`sm`})})]}),g]}):(0,S.jsxs)(`div`,{className:`pane-done`,children:[(0,S.jsx)(Iu,{drawn:!0}),(0,S.jsx)(`h2`,{children:f}),h,g,_]})}var Fu=[0,1,2,3,4,5,6,7];function Iu({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:Fu.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)(W,{name:`check`,size:`md`})]})}function Lu({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=Os(),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)(W,{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)(W,{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)(W,{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)(W,{name:`x`,size:`sm`})})]}):(0,S.jsxs)(`div`,{className:`empty-state landed-full`,children:[(0,S.jsx)(W,{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 Ru({layer:e,filesShown:t,comments:n}){let r=e.summary?_s(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=hs(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)(W,{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)(Ac,{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)(wl,{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)($c,{threads:c,actions:n.actions,showContext:!0,agentConnected:n.agentConnected,workingOn:n.workingOn,queuedOn:n.queuedOn,links:n.links}),i&&(0,S.jsx)(Lc,{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 zu={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=zt(e,t),_=e.path.lastIndexOf(`/`),v=zu[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)(W,{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),Ot(e.path).then(()=>{u(!0),clearTimeout(p.current),p.current=setTimeout(()=>u(!1),1500)})},children:(0,S.jsx)(W,{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]})]}),ku(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)(W,{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)(Ea,{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)(W,{name:`chat`,size:`sm`}),(0,S.jsx)(`span`,{className:`ghb-badge`,children:i})]}),(0,S.jsx)(`span`,{onClick:y,children:(0,S.jsx)(Do,{label:`More file actions`,triggerClassName:`ghb`,children:t=>(0,S.jsxs)(S.Fragment,{children:[s&&(0,S.jsx)(Oo,{icon:`chat`,onClick:()=>{t(),s()},children:`Comment on this file`}),(0,S.jsx)(Oo,{icon:`copy`,onClick:()=>{t(),Ot(e.path)},children:`Copy path`}),(0,S.jsx)(Oo,{icon:`fold`,kbd:`o`,onClick:()=>{t(),r?.()},children:n?`Expand file`:`Collapse file`})]})})}),d&&(0,S.jsx)(`span`,{onClick:y,children:(0,S.jsx)(Au,{path:e.path,onClose:()=>f(!1)})})]})}function Vu(e){return{fingerprint:e,headLines:null,exp:new Map,failed:new Set}}function Hu(e){let t=(0,x.useMemo)(()=>_l(e),[e]),n=(0,x.useMemo)(()=>`${e.newLineCount??``}#${e.hunks.map(e=>e.id).join(`
|
|
87
87
|
`)}`,[e]),[r,i]=(0,x.useState)(()=>Vu(n));r.fingerprint!==n&&i(Vu(n));let a=r.fingerprint===n?r:Vu(n),o=async(t,r)=>{let o=a.headLines;if(o===null)try{let t=e.rev?`&rev=${encodeURIComponent(e.rev)}`:``,n=await fetch(`/api/file?path=${encodeURIComponent(e.path)}&side=head${t}`);if(!n.ok)throw Error(`/api/file → ${n.status}`);let r=await n.text();o=r.endsWith(`
|
|
88
88
|
`)?r.slice(0,-1).split(`
|
|
89
89
|
`):r.split(`
|
|
90
90
|
`)}catch{i(e=>e.fingerprint===n?{...e,failed:new Set(e.failed).add(t.key)}:e);return}let s=a.exp.get(t.key)??cl,c=r===`all`?{fromTop:vl(t),fromBottom:0}:r===`down`?{...s,fromTop:s.fromTop+20}:{...s,fromBottom:s.fromBottom+20},l=xl(o,t,s),u=xl(o,t,c),d=o;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):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,xl(a.headLines,n,t))}return e},[t,a]);return{gaps:t,visible:c,controlsFor:e=>{let t=a.exp.get(e.key)??cl;return{remaining:yl(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 Uu({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}=Hu(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)($c,{threads:p,actions:f.actions,showContext:!0,agentConnected:f.agentConnected,workingOn:f.workingOn,queuedOn:f.queuedOn}),i&&(0,S.jsx)(Lc,{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 (${ol(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)(Ou,{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 _=zt(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)(Ou,{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)(Eu,{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)(hu,{gap:d(b)})]})}function Wu({files:e,delta:t=Sl,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&&sl(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)||!zt(e,i))continue;let t=document.getElementById(ka(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=Os(),ee=O?.partition.changeset.length??0,I=F?.viewer.login??null,L=O?.partition.changeset,{lead:te,others:ne}=(0,x.useMemo)(()=>{let e=L??[];if(!F)return{lead:e,others:[]};let t=e=>e.github?.kind===`description`||!U(e)||zs(e,I);return{lead:e.filter(t),others:e.filter(e=>!t(e))}},[L,F,I]),[re,R]=(0,x.useState)(!1),ie=O?.revealThreadId??null;(0,x.useEffect)(()=>{k>0&&ie!==null&&ne.some(e=>e.id===ie)&&R(!0)},[k,ie,ne]);let ae=O&&j&&(ee>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)(W,{name:`chev`})}),F?`On the pull request`:`On the changeset`,(0,S.jsx)(`span`,{className:`strip-n`,children:ee})]}),A&&(0,S.jsxs)(`div`,{className:`strip-body`,children:[(0,S.jsx)($c,{threads:te,actions:O.actions,showContext:!0,agentConnected:O.agentConnected,workingOn:O.workingOn,queuedOn:O.queuedOn,links:O.links}),ne.length>0&&(0,S.jsx)(`button`,{type:`button`,className:`strip-more`,"aria-expanded":re,onClick:()=>R(!re),children:re?`Only mine`:`${ne.length} more from others`}),re&&ne.length>0&&(0,S.jsx)($c,{threads:ne,actions:O.actions,showContext:!0,agentConnected:O.agentConnected,workingOn:O.workingOn,queuedOn:O.queuedOn,links:O.links}),O.changesetComposerOpen?(0,S.jsx)(Lc,{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`})]})]}),oe=O?.past??[],se=oe.filter(e=>e.github?.outdated===!0).length,ce=oe.filter(e=>e.anchor.kind===`layer`).length,le=ce===oe.length?`The layer ${oe.length===1?`this hangs`:`these hang`} off left the outline: the agent re-posted without ${oe.length===1?`its`:`their`} title.`:se===oe.length?`${oe.length===1?`This one is`:`These are`} outdated on GitHub: the line ${oe.length===1?`it hangs`:`they hang`} off left the diff, though the file is still in it.`:se>0?`The file or change these hang off is no longer in the diff: reverted, deleted, or stashed; ${se} ${se===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.`,ue=O&&oe.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)(W,{name:`chev`})}),(0,S.jsxs)(`span`,{className:`file-path`,children:[oe.length===1?`1 thread`:`${oe.length} threads`,` whose`,` `,ce===oe.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:[le,` The conversation is intact`,ce===oe.length?`.`:`, and the snapshot inside each one is the code you commented on.`]}),(0,S.jsx)($c,{threads:oe,actions:O.actions,showContext:!0,gone:!0,agentConnected:O.agentConnected,workingOn:O.workingOn,queuedOn:O.queuedOn})]})]}),de=a?.total??0,z=e.length===0&&de===0,B=e.length===0&&de>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)(Pu,{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)(Lu,{...o,shape:`full`}):(0,S.jsxs)(`div`,{className:`empty-state`,children:[(0,S.jsx)(W,{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)(Ru,{layer:s,filesShown:0,comments:O}):B&&fe?me:B&&a?(0,S.jsxs)(`div`,{className:`empty-state`,children:[(0,S.jsx)(W,{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)(Ru,{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:sl(e),f=n===void 0?0:e.hunks.reduce((e,t)=>e+ +!!n.has(t.id),0);return(0,S.jsxs)(`section`,{id:ka(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)(Uu,{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)(W,{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)(ju,{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)(Lu,{...o,shape:`docked`}),ae,ue,he]}),fe&&!B&&!f&&me]})}var Gu=[{name:`Move`,keys:[[`j`,`Next hunk`],[`k`,`Previous hunk`],[`J`,`Next file`],[`K`,`Previous file`],[`n`,`Next unreviewed file`],[`]`,`Next layer or commit`],[`[`,`Previous layer or commit`],[`.`,`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 Ku({onClose:e}){return(0,S.jsx)(Ft,{title:`Shortcuts`,onClose:e,children:(0,S.jsx)(`div`,{className:`keys`,children:Gu.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 qu={COMMENT:`Commented`,APPROVE:`Approved`,REQUEST_CHANGES:`Changes requested`};function Ju({coverage:e,presence:t,onFinish:n,onInvite:r,onClose:i}){let a=Os(),o=Et(!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})=>{t?.failed?(y(t.failed),o.refetch()):(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`,ee=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)(W,{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)(W,{name:`globe`,size:`sm`}),` Submit to GitHub `,(0,S.jsx)(`kbd`,{className:`sub-kbd`,children:`⌘↵`})]})})]});return(0,S.jsxs)(Ft,{title:b?`Review submitted to GitHub`:`Submit review to GitHub`,wide:!0,className:`sub-modal`,onClose:i,footer:ee,children:[a&&(0,S.jsxs)(`div`,{className:`sub-where`,children:[(0,S.jsx)(W,{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:Nc.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&&Ic(s.current,e,l),children:(0,S.jsx)(W,{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)(Ac,{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)(W,{name:`check`,size:`md`})}),(0,S.jsxs)(`div`,{className:`sub-done-text`,children:[(0,S.jsx)(`b`,{children:b.submitted?qu[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)(W,{name:`link`,size:`sm`})]})]}),(0,S.jsxs)(`p`,{className:`sub-done-agent`,children:[(0,S.jsx)(W,{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)(W,{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 Yu={showDelay:600,leaveGrace:500},Xu=class{hooks;timing;armed=null;shown=null;showTimer;hideTimer;constructor(e,t=Yu){this.hooks=e,this.timing=t}over(e){this.shown&&this.hooks.same(e,this.shown)?this.cancelHide():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}},Z=/[A-Za-z_$][\w$]*/g;function Q(e,t){Z.lastIndex=0;for(let n of e.matchAll(Z)){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 Zu=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 Qu(e){return e.length>0&&!Zu.has(e)}function $u(e,t){return t===`base`?e!==`add`:e!==`del`}function ed(e){return e.replace(/[$\\]/g,`\\$&`)}function td(e,t,n){if(!t)return[];let r=RegExp(`(?<![\\w$])${ed(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(!$u(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 nd(e){return e.reduce((e,t)=>e+t.usages.length,0)}var rd=`sym-occ`;function id({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 Xu({same:(e,t)=>e.cell===t.cell&&e.start===t.start&&e.word===t.word,show:e=>{hd(e.word,e.side),r(e)},hide:()=>{gd(),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?md(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?td(e,n.word,n.side):[],[e,n]);return(0,x.useLayoutEffect)(()=>{let e=i.current;if(!e||!n)return;let t=pd(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)(ad,{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 ad({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=nd(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=>od(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)(W,{name:`chev`,size:`sm`}),(0,S.jsx)(sd,{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&&od(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)(ld,{usage:e})]},`${e.hunkId}:${e.line}`)})]},e.path)})})]})}function od(e,t){return e.hunkId===t.hunkId&&e.line===t.line}function sd({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 cd=28;function ld({usage:e}){let t=e.text,n=t.search(/\S|$/),r=!1;e.col-n>cd&&(n=t.lastIndexOf(` `,e.col-cd+8)+1,(n<=0||e.col-n>56)&&(n=e.col-cd),r=!0);let i=t.slice(n,e.col),a=t.slice(e.col,e.col+ud(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 ud(e,t){let n=Q(e,t);return n&&n.start===t?n.end-t:0}function dd(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 fd(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 pd(e,t,n){let r=document.createRange(),i=0,a=!1;for(let o of fd(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 md(e,t,n,r){let i=e.closest?.(`td[data-side]`);if(!(i instanceof HTMLElement)||e.closest(`.nosym`))return null;let a=dd(t,n);if(!a||a.node.nodeType!==Node.TEXT_NODE||!i.contains(a.node))return null;let o=a.offset;for(let e of fd(i)){if(e===a.node)break;o+=e.data.length}let s=Q(i.textContent??``,o);if(!s||!Qu(s.word))return null;let c=pd(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 hd(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=pd(t,n.index,n.index+n[0].length);e&&i.add(e)}}}n.set(rd,i)}function gd(){globalThis.CSS?.highlights?.delete(rd)}var _d=12e3;function vd({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)(_d),[l,u]=(0,x.useState)(_d);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)(W,{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:yd}),(0,S.jsx)(`circle`,{className:`telemetry-notice-ring-left`,cx:`20`,cy:`20`,r:yd,strokeDasharray:bd,strokeDashoffset:bd*(1-l/_d)})]}),(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 yd=18,bd=2*Math.PI*yd;function xd(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function Sd({item:e,current:t,onOpen:n,onResolve:r,onReopen:i,onDelete:a}){let o=e.turn===`resolved`,s=st(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)(W,{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)(W,{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`&&U(e.thread)&&(0,S.jsx)(`span`,{className:`crow-pill`,children:`Draft`}),ot(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)(W,{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:Rc[e.thread.intent]}),(0,S.jsx)(`span`,{className:`crow-sep`,children:`·`})]}),(0,S.jsx)(`span`,{className:`crow-where${e.gone?` crow-where-gone`:``}`,children:xd(u)}),U(e.thread)?wd(e)&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`crow-sep`,children:`·`}),(0,S.jsx)(`span`,{className:`crow-state`,children:wd(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:Cd(e)})]})]})]}),(0,S.jsx)(`span`,{className:`crow-when`,children:Ta(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)(W,{name:`trash`,size:`sm`})})]})}function Cd(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, ${Hc(e.queued)}`;case`note`:return`draft, not sent`;case`posted`:return e.answer??`on GitHub`;case`resolved`:return e.answer??`resolved`}}function wd(e){let t=e.thread;if(e.turn===`note`)return null;if(ct(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=Td(t);return e.turn===`resolved`?n?`${n} · resolved`:`resolved`:n??`on GitHub`}function Td(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 Ed=new Set([`settled`]),Dd={github:{icon:`globe`,label:`GitHub`,empty:`No PR comments yet`},agent:{icon:`lock`,label:`Private`,empty:`Nothing asked of the agent yet`}},Od=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function kd(e,t){let n=e=>t.filter(e).length;if(e===`github`){let e=n(e=>e.turn===`note`);return e>0?{text:Od(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 Ad({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=Os()?.viewer.login??null,p=Dd[e],m=kd(e,t),h=t.filter(e=>e.turn!==`resolved`),g=t.filter(e=>e.turn===`resolved`),_=e===`github`?h.filter(e=>zs(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)(W,{name:`chev`,size:`sm`})}),(0,S.jsx)(W,{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 jd({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)(Ed),f=(0,x.useMemo)(()=>[...e,...t.map(e=>({...e,gone:!0}))],[e,t]),p=(0,x.useMemo)(()=>Ws(f),[f]),m=(0,x.useMemo)(()=>l?Bs(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)(Sd,{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)(Ad,{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)(W,{name:`chev`,size:`sm`})}),Ps[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)(W,{name:r.icon,size:`sm`})})]}),!n&&t.map(_)]},e)}),g]})}var Md=`diffo:ui:critter`;function Nd(){try{return localStorage.getItem(Md)!==`off`}catch{return!0}}function Pd(e){try{e?localStorage.removeItem(Md):localStorage.setItem(Md,`off`)}catch{}}async function Fd(){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 Id(e){e?document.documentElement.removeAttribute(`data-motion`):document.documentElement.setAttribute(`data-motion`,`off`)}function Ld(){let[e,t]=(0,x.useState)(Nd);return(0,x.useEffect)(()=>{Id(e)},[e]),(0,x.useEffect)(()=>{let e=!1;return Fd().then(n=>{e||n===null||n===Nd()||(Pd(n),t(n))}),()=>{e=!0}},[]),[e,(0,x.useCallback)(e=>{t(e),Pd(e),fetch(`/api/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({critter:e?`on`:`off`})}).catch(()=>{})},[])]}function Rd(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 zd(e){return e instanceof HTMLElement?e.tagName===`INPUT`||e.tagName===`TEXTAREA`||e.isContentEditable:!1}var Bd={changedHunkIds:new Set,changedFiles:[],changed:new Set},Vd=new Set,Hd=e=>e.hunks.length>0;function Ud(e,t,n=Vd){if(!e||!t)return Bd;let r=new Set(t.hunkIds),i=new Set,a=[];for(let t of e.files){if(!Hd(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=it({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 Gd=`diffo:ui:theme`;function Kd(e){return e===`system`||e===`light`||e===`dark`?e:null}function qd(){let e=localStorage.getItem(Gd);return e===`light`||e===`dark`?e:`system`}function Jd(e){e===`system`?localStorage.removeItem(Gd):localStorage.setItem(Gd,e)}function Yd(e){e===`system`?document.documentElement.removeAttribute(`data-theme`):document.documentElement.setAttribute(`data-theme`,e)}async function Xd(){try{let e=await fetch(`/api/settings`);return e.ok?Kd((await e.json())?.theme):null}catch{return null}}function Zd(e){fetch(`/api/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({theme:e})}).catch(()=>{})}function Qd(){let[e,t]=(0,x.useState)(qd);return(0,x.useEffect)(()=>{let e=!1;return Xd().then(n=>{e||n===null||n===qd()||(Jd(n),Yd(n),t(n))}),()=>{e=!0}},[]),[e,(0,x.useCallback)(e=>{t(e),Yd(e),Jd(e),Zd(e)},[])]}var $d=(e,t)=>`${e}:${t}`;function ef(e){return e.flatMap(e=>e.messages.filter(e=>e.author===`agent`).map(t=>$d(e.id,t.id)))}function tf(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 nf(e,t){let n=[];for(let r of e){let e=[...r.messages].reverse().find(e=>e.author===`agent`);if(!e||t.has($d(r.id,e.id)))continue;let i=dt(r);n.push({key:$d(r.id,e.id),kind:i?r.anchor.kind===`changeset`?`guide`:`thread`:`answer`,threadId:r.id,anchor:tf(r),preview:e.text.split(`
|
|
91
|
-
`,1)[0].trim()})}return n}function rf(e,t){return e>0?`(${e}) ${t}`:t}function af(e,t,n=!1){return e?n?`dev · ${e}`:e:t}var of=8e3;function sf(e,t){let n=0;return e.map(e=>e.kind===`guide`?e:{...e,expiresAt:t+350*n++})}function cf(e,t){let n=-1/0;for(let t of e)t.expiresAt!==null&&t.expiresAt>n&&(n=t.expiresAt);return Math.max(t+of,n+350)}function lf(e){let t=document;if(typeof t.startViewTransition!=`function`){e();return}let n=t.startViewTransition(()=>(0,Pt.flushSync)(e));n.ready.catch(()=>{}),n.finished.catch(()=>{})}function uf({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)(ro()),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=rf(l.current,af(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(ef(e));return}let t=nf(e,a.current);for(let t of ef(e))a.current.add(t);if(t.length===0)return;if(document.hasFocus()){let e=Date.now(),n=t.map(e=>({...e,expiresAt:null}));lf(()=>i(t=>[...t,...sf(n,cf(t,e))]));return}l.current+=t.length,d();let n=t.map(e=>({...e,expiresAt:null}));lf(()=>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()+of;i(t=>sf(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();lf(()=>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)(()=>lf(()=>i([])),[]),p=(0,x.useCallback)(e=>{lf(()=>i(t=>t.filter(t=>t.key!==e.key)))},[]);return{notices:r,open:(0,x.useCallback)(e=>{lf(()=>i(t=>t.filter(t=>t.key!==e.key))),u.current(e.threadId)},[]),dismiss:p,clear:f}}function df(e){return`diffo:viewed:${e.repo.path}:${pf(e)}`}function ff(e){return`diffo:viewed:${e.repo.name}:${pf(e)}`}function pf(e){return e.spec.kind===`working-tree`?`working-tree`:`branch:${e.spec.base}`}function mf(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 hf(e,t){try{localStorage.setItem(e,JSON.stringify([...t]))}catch{}}function gf(e){let t=e?df(e):null,n=e?ff(e):null,[r,i]=(0,x.useState)(new Set),[a,o]=(0,x.useState)(!1);(0,x.useEffect)(()=>{if(!t)return;let e=mf(t);if(e.size===0&&n!==null&&n!==t){let e=mf(n);if(e.size>0){hf(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=Lt(r),a=i.every(e=>n.has(e));for(let e of i)a?n.delete(e):n.add(e);return t&&hf(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 Lt(t))r?i.add(e):i.delete(e);return t&&hf(t,i),i})},[e,t]),l=(0,x.useCallback)((e,n)=>{i(r=>{let i=new Set(r);for(let t of e)n?i.add(t):i.delete(t);return t&&hf(t,i),i})},[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]),setMarks:l,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++,zt(i,r)&&n++;return{viewed:n,total:t}},[e,r])}}var _f=new Ge,vf=264,yf=800,bf=200,xf=520,Sf=e=>Math.min(xf,Math.max(bf,e)),Cf=12,wf=`overview`,Tf=16,Ef=new Set,Df=new Map;function Of(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 kf=[],Af=[];function jf(){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)(Ef),[d,f]=(0,x.useState)(Df),[p,m]=(0,x.useState)(Ef);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`)):Ef),f(r!==`waiting`&&Array.isArray(t.queued)?new Map(t.queued.filter(e=>typeof e==`string`).map((e,t)=>[e,t+1])):Df),m(r!==`waiting`&&Array.isArray(t.answered)?new Set(t.answered.filter(e=>typeof e==`string`)):Ef))}catch{}}),t.onopen=()=>{e.invalidateQueries({queryKey:[`review`]}),e.invalidateQueries({queryKey:[`changeset`]})},t.onerror=()=>{n(`waiting`),o(`disconnected`),c(null),u(Ef),f(Df),m(Ef),i(null)},()=>t.close()},[e]),{presence:t,reason:a,since:s,workingOn:l,queuedOn:d,answeredOn:p,layersRequest:r}}function Mf(e,t,n){let[r,i]=(0,x.useState)(null),a=(0,x.useRef)(Ef);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(Hs(s.anchor))},[e,t,n]),r}function Nf(){let e=w();return(0,x.useMemo)(()=>{let t=()=>e.invalidateQueries({queryKey:[`review`]});return{create:async(e,n,r,i)=>{let a=await Dt.createThread(e,n,r,i);return await t(),a},reply:(e,n,r)=>Dt.reply(e,n,r).then(t),edit:(e,n,r,i)=>Dt.editMessage(e,n,r,i).then(t),send:async e=>{let{prompt:n,delivered:r,presence:i}=await Dt.send(e);if(r||i!==`waiting`)return await t(),{delivered:!0};let a=await Ot(n);return await t(),{delivered:!1,copied:a,prompt:n}},resolve:e=>Dt.setState(e,`resolved`).then(t),reopen:e=>Dt.setState(e,`open`).then(t),remove:e=>Dt.remove(e).then(t),dismissPrComment:(e,n)=>Dt.dismissPrComment(e,n).then(t)}},[e])}function Pf(){let{data:e,isLoading:t,error:n}=_t(),{presence:r,reason:i,since:a,workingOn:o,queuedOn:s,answeredOn:c,layersRequest:l}=jf(),{viewed:u,loaded:d,toggleFile:f,markFiles:p,clearFiles:m,setMarks:h,progress:g,fileProgress:_}=gf(e),[v,y]=(0,x.useState)(`unified`),[b,C]=(0,x.useState)(null),[w,T]=(0,x.useState)(null),[E,D]=(0,x.useState)(new Set),[O,k]=(0,x.useState)(()=>{let e=localStorage.getItem(`diffo:ui:navHidden`);return e===null?window.innerWidth<yf:e===`1`}),[A,j]=(0,x.useState)(()=>{let e=Number(localStorage.getItem(`diffo:ui:railWidth`));return e>0?Sf(e):vf}),[M,N]=(0,x.useState)(!1),P=(0,x.useRef)(null),F=(0,x.useRef)(A);F.current=M?F.current:A;let ee=(0,x.useRef)(null);(0,x.useEffect)(()=>()=>ee.current?.(),[]);let{data:I}=bt(),L=Nf(),[te,ne]=(0,x.useState)(null),[re,R]=(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),[z,B]=(0,x.useState)(!1),[fe,pe]=Qd(),[me,he]=Ld(),ge=Wd(),[_e,ve]=(0,x.useState)(!1),[ye,be]=(0,x.useState)(`files`),[xe,Se]=(0,x.useState)(0),Ce=e?.pr??null,we=r!==`waiting`,[Te,Ee]=(0,x.useState)(!1),De=(0,x.useMemo)(()=>Ud(e,I?.lastFinish,u),[e,I,u]),Oe=(0,x.useMemo)(()=>Ua(e?.files??[]),[e]),V=Ra(Oe,(0,x.useCallback)(e=>zt(e,u),[u]),{on:Te,changed:De.changed,set:Ee}),ke=(0,x.useMemo)(()=>$o(I?.layers,Oe),[I?.layers,Oe]),Ae=ke.length>0,je=(0,x.useMemo)(()=>is(ke),[ke]),Me=(0,x.useMemo)(()=>V.hideTests?es(ke,e=>Ma(e.path)&&!V.pinned.has(e.path)):ke,[ke,V.hideTests,V.pinned]),[Ne,Pe]=(0,x.useState)(null),[Fe,Ie]=(0,x.useState)(null);(0,x.useEffect)(()=>Ie(null),[Ne]);let Le=(0,x.useMemo)(()=>ns(I?.threads??[]),[I?.threads]),Re=(0,x.useMemo)(()=>Ce?rs(I?.threads??[]):void 0,[Ce,I?.threads]),ze=Le!==void 0||Re!==void 0,Be=Ae&&Ne===wf&&ze,Ve=ke.findIndex(e=>ts(e)===Ne),He=(0,x.useMemo)(()=>ke.every(e=>e.files.every(e=>!zt(e.file,u))),[ke,u]),Ue=Ae?Be?-1:Ve===-1?ls(Me,u):Ve:-1,We=Ae&&Ue>=0?Me[Ue]:void 0,Ge=Ae&&Ue>=0?ke[Ue]:void 0,Ke=vt(e?.version,e?.spec.kind===`branch`),H=Ke.data?.commits??Af,qe=H.length>0,[Je,Ye]=(0,x.useState)(null),Xe=qe&&Je===`commits`?`commits`:`steps`,Ze=ye===`layers`&&Xe===`commits`,Qe=Ae&&ye===`layers`&&!Ze,$e=Qe?We:void 0;(0,x.useEffect)(()=>{Ae&&d&&Ve===-1&&!Be&&Pe(ze&&He&&Ne===null?wf:ts(ke[Ue]))},[Ae,d,Ve,Be,ke,Ue,ze,He,Ne]);let[et,tt]=(0,x.useState)(!1);(0,x.useEffect)(()=>{Ze&&tt(!0)},[Ze]);let nt=yt((0,x.useMemo)(()=>et?H.map(e=>e.sha):[],[et,H]),e?.version),[rt,it]=(0,x.useState)(null),at=H.findIndex(e=>e.sha===rt),ot=at===-1?H.length===0?-1:Math.max(0,H.findIndex(e=>{let t=nt.get(e.sha);return t===void 0||t.some(e=>!zt(e,u))})):at,U=ot>=0?H[ot]:void 0,ct=U?nt.get(U.sha):void 0,lt=(0,x.useMemo)(()=>ct?Ua(ct):void 0,[ct]),ut=Ze&<!==void 0;(0,x.useEffect)(()=>{Ze&&d&&at===-1&&ut&&U&&it(U.sha)},[Ze,d,at,ut,U]);let ft=(0,x.useMemo)(()=>Ze?lt??kf:Qe&&Be?[]:$e?$e.files.map(e=>e.file):V.files,[Ze,lt,Qe,Be,$e,V.files]),pt=(0,x.useCallback)(e=>e.files.length===0,[]),[ht,xt]=(0,x.useState)(Cf),St=(0,x.useCallback)(()=>xt(e=>e+Cf),[]),Ct=(0,x.useCallback)(e=>{let t=ke[e];t&&(Pe(ts(t)),C(null),T(null),xt(Cf),requestAnimationFrame(()=>{document.querySelector(`.reading-pane`)?.scrollTo({top:0})}))},[ke]),wt=(0,x.useCallback)(()=>{Pe(wf),C(null),T(null),requestAnimationFrame(()=>{document.querySelector(`.reading-pane`)?.scrollTo({top:0})})},[]),Tt=(0,x.useCallback)(e=>{it(e),C(null),T(null),xt(Cf),requestAnimationFrame(()=>{document.querySelector(`.reading-pane`)?.scrollTo({top:0})})},[]),Et=(0,x.useCallback)(e=>{if(!Qe||Ge?.files.some(t=>t.file.path===e))return;let t=je.get(e);t&&Ct(ke.indexOf(t))},[Qe,Ge,je,ke,Ct]),Ot=$e?.kind===`mechanical`?ts($e):null,kt=(0,x.useRef)($e);kt.current=$e;let jt=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(Ot===null)return;let e=jt.current,t=(kt.current?.files??[]).map(e=>e.file.path).filter(t=>t!==e);D(e=>new Set([...e,...t]))},[Ot]),(0,x.useEffect)(()=>{Ae&&be(`layers`)},[Ae]);let Mt=(0,x.useCallback)(()=>{Dt.requestLayers().catch(()=>{})},[]),Pt=(0,x.useCallback)(e=>{V.pin(e);let t=Qe?Ge?.files.some(t=>t.file.path===e)?Ge:je.get(e):void 0,n=ut?ft.findIndex(t=>t.path===e):t?t.files.findIndex(t=>t.file.path===e):Oe.findIndex(t=>t.path===e);n>=0&&xt(e=>Math.max(e,n+1))},[Oe,V.pin,Qe,Ge,je,ut,ft]),Ft=(0,x.useMemo)(()=>ft.slice(0,ht),[ft,ht]),{active:Rt,past:G}=(0,x.useMemo)(()=>{let t=mt(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]),Bt=(0,x.useMemo)(()=>ut?nu(lt,e?.files??kf,Rt):eu(e?.files??[],Rt),[e,Rt,ut,lt]),Vt=(0,x.useMemo)(()=>Vs(Rt,o,s),[Rt,o,s]),Ht=(0,x.useMemo)(()=>({stillTo:Vt.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:Vt.filter(e=>c.has(e.thread.id))}),[Vt,c]),Ut=(0,x.useMemo)(()=>({segments:[...Ht.back.map(()=>`done`),...Ht.stillTo.map(e=>e.working===!0?`now`:`wait`)],done:Ht.back.length}),[Ht]),Wt=Mf(Vt,c,r),Gt=r===`working`?Us(Ht.stillTo,Wt)??(l===`outlining`?`outlining layers`:null):null,[Kt,qt]=(0,x.useState)(!1);(0,x.useEffect)(()=>{Kt&&Ht.stillTo.length===0&&Ht.back.length===0&&qt(!1)},[Kt,Ht]),(0,x.useEffect)(()=>{Te&&De.changed.size===0&&Ee(!1)},[Te,De]);let Jt=(0,x.useMemo)(()=>Vs(G),[G]),Yt=(0,x.useMemo)(()=>qs(Vt),[Vt]),Xt=(0,x.useMemo)(()=>ru(e?.files??[],Bt),[e,Bt]),Zt=Gs(Vt)+Gs(Jt),Qt=Ks(Vt)+Ks(Jt),$t=Vt.length+Jt.length-Qt,[en,tn]=(0,x.useState)(0),[nn,rn]=(0,x.useState)(0),[an,on]=(0,x.useState)(null),[sn,cn]=(0,x.useState)(null),ln=ut?U?.sha??null:null,un=(0,x.useMemo)(()=>ln===null?L:{...L,create:(e,t,n,r)=>L.create(e,t,n,{...r,commit:ln})},[L,ln]),dn=(0,x.useMemo)(()=>({partition:Bt,past:G,actions:un,agentConnected:we,workingOn:o,queuedOn:s,composeHunkId:te,onComposeHandled:()=>ne(null),composeFilePath:re,onComposeFileHandled:()=>R(null),changesetComposerOpen:ie,onOpenChangesetComposer:()=>ae(!0),onCloseChangesetComposer:()=>ae(!1),revealNotesTick:en,revealPastTick:nn,revealThreadId:an}),[Bt,G,un,we,o,s,te,re,ie,en,nn,an]),fn=(0,x.useMemo)(()=>{let e=0;for(let t of Rt)As(t)&&e++;return e},[Rt]),pn=(0,x.useMemo)(()=>Rt.filter(st).length+G.filter(st).length,[Rt,G]),[mn,hn]=(0,x.useState)(new Set),gn=(0,x.useMemo)(()=>{let e=new Set;for(let t of Rt)dt(t)||(t.anchor.kind===`hunk`||t.anchor.kind===`file`)&&e.add(t.anchor.path);return e},[Rt]),_n=(0,x.useMemo)(()=>{let e=Oe.filter(e=>!zt(e,u)),t=e.filter(e=>mn.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:g.viewed,totalHunks:g.total,viewedFiles:_.viewed,totalFiles:_.total,changedFiles:t,commentedUnread:i.filter(e=>gn.has(e.path)).map(e=>e.path),filteredOut:i.filter(e=>!gn.has(e.path)&&r.has(e.path)).map(e=>e.path),skippedFiles:i.filter(e=>!gn.has(e.path)&&!r.has(e.path)).map(e=>e.path)}},[Oe,g,_,u,mn,gn,V.scope.excludedPaths]),vn=(0,x.useCallback)(async()=>{await Dt.clear(),await _f.invalidateQueries({queryKey:[`review`]})},[]),yn=(0,x.useCallback)(()=>{_f.setQueryData([`review`],e=>e&&{...e,landed:void 0}),Dt.dismissLanded().then(()=>_f.invalidateQueries({queryKey:[`review`]}))},[]),bn=(0,x.useMemo)(()=>{if(I?.landed)return{sha:I.landed.sha,subject:I.landed.subject,threads:I.threads.length,onClear:vn,onDismiss:yn}},[I,vn,yn]),xn=(0,x.useMemo)(()=>{let e=e=>e.turn===`yours`||e.turn===`unanswered`;return[...Vt.filter(e),...Jt.filter(e).map(e=>({...e,gone:!0}))]},[Vt,Jt]),Sn=(0,x.useCallback)(async()=>{await _f.invalidateQueries({queryKey:[`review`]}),await _f.invalidateQueries({queryKey:[`finish-preview`]})},[]),Cn=(0,x.useCallback)(e=>Dt.setState(e,`resolved`).then(Sn),[Sn]),wn=(0,x.useCallback)(e=>Dt.setState(e,`open`).then(Sn),[Sn]),Tn=(0,x.useCallback)(async(e,t)=>{let n={..._n,...t&&t.note.trim()!==``?{note:t.note.trim()}:{}},{prompt:r,delivered:i,presence:a,public:o}=await Dt.finish(n,e,t?.event);await _f.invalidateQueries({queryKey:[`review`]}),await _f.invalidateQueries({queryKey:[`changeset`]}),await _f.invalidateQueries({queryKey:[`finish-preview`]});let s=i||a!==`waiting`;return e&&s&&fn>0&&!o?.failed&&qt(!0),{prompt:r,delivered:s,...o?{public:o}:{}}},[_n,fn]),En=(0,x.useCallback)(e=>{let t=Sf(e);F.current=t,j(t),localStorage.setItem(`diffo:ui:railWidth`,String(t))},[]),Dn=(0,x.useCallback)(e=>{if(e.button!==0)return;e.preventDefault();let t=e.clientX,n=F.current,r=n,i=e=>{r=Sf(n+e.clientX-t),F.current=r,P.current?.style.setProperty(`--rail-w`,`${r}px`)},a=()=>{ee.current?.(),ee.current=null,N(!1),En(r)};ee.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`,N(!0)},[En]),On=(0,x.useCallback)(()=>En(vf),[En]),kn=(0,x.useRef)(localStorage.getItem(`diffo:ui:navHidden`)!==null),An=(0,x.useCallback)(()=>{kn.current=!0,k(e=>!e)},[]);(0,x.useEffect)(()=>{kn.current&&localStorage.setItem(`diffo:ui:navHidden`,O?`1`:`0`)},[O]);let K=(0,x.useRef)(!1);(0,x.useEffect)(()=>{if(K.current||!d||!e)return;K.current=!0;let t=e.files.filter(e=>zt(e,u)).map(e=>e.path);t.length>0&&D(e=>new Set([...e,...t]))},[d,e,u]);let jn=(0,x.useCallback)(e=>{D(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Mn=(0,x.useRef)(null),Nn=(0,x.useCallback)(e=>{let t=document.querySelector(`.reading-pane`),n=document.getElementById(ka(e));if(!t||!n)return;let r=t.getBoundingClientRect().top,i=n.getBoundingClientRect(),a=i.top-r+t.scrollTop;i.bottom<=r?Mn.current=t.scrollTop-(i.height+Tf):i.top<=r&&(Mn.current=a)},[]);(0,x.useLayoutEffect)(()=>{let e=Mn.current;if(e===null)return;Mn.current=null;let t=document.querySelector(`.reading-pane`);t&&(t.scrollTop=Math.max(0,e))});let Pn=(0,x.useCallback)(t=>{let n=ut?lt.find(e=>e.path===t):void 0,r=n??e?.files.find(e=>e.path===t);if(!r)return;let i=zt(r,u);!i&&V.hideReviewed&&!n&&(Nn(t),V.unpin(t)),n?h(Lt(n),!i):f(t),D(e=>{let n=new Set(e);return i?n.delete(t):n.add(t),n})},[e,f,u,V.hideReviewed,V.unpin,Nn,ut,lt,h]),Fn=(0,x.useCallback)(e=>{h(e.flatMap(Lt),!0),D(t=>new Set([...t,...e.map(e=>e.path)]))},[h]),In=(0,x.useCallback)(e=>{h(e.flatMap(Lt),!1),D(t=>{let n=new Set(t);for(let t of e)n.delete(t.path);return n})},[h]),Ln=(0,x.useCallback)(e=>{let t=n=>{let r=document.getElementById(ka(e));r?Aa(r,Of):n>0&&requestAnimationFrame(()=>t(n-1))};requestAnimationFrame(()=>t(30))},[]),Rn=(0,x.useCallback)(e=>{Et(e),Pt(e),D(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n}),Ln(e)},[Pt,Et,Ln]),zn=(0,x.useCallback)((t,n)=>{let r=e?.files.find(e=>e.path===t);if(!r)return;Et(t),Pt(t),D(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?(C(i.id),T(null),requestAnimationFrame(()=>{let e=t=>{let n=document.querySelector(`[data-hunk-id="${i.id}"]`);n?Aa(n,Of):t>0&&requestAnimationFrame(()=>e(t-1))};e(30)})):Ln(t)},[e,Et,Pt,Ln]),Bn=(0,x.useCallback)(({path:t,side:n,line:r})=>{let i=e?.files.find(e=>e.path===t);if(!i)return;Et(t),Pt(t),D(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){Ln(t);return}C(a.id),T(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?Aa(n,Of,`center`):t>0&&requestAnimationFrame(()=>e(t-1))};e(30)})},[e,Et,Pt,Ln]),Vn=(0,x.useMemo)(()=>({paths:Oe.map(e=>e.path),onJump:zn}),[Oe,zn]),Hn=(0,x.useMemo)(()=>({...dn,links:Vn}),[dn,Vn]),Un=(0,x.useCallback)(e=>{p(e);for(let t of e)V.unpin(t);D(t=>new Set([...t,...e]))},[p,V.unpin]),Wn=(0,x.useCallback)(e=>{m(e),D(t=>{let n=new Set(t);for(let t of e)n.delete(t);return n})},[m]),Gn=(0,x.useCallback)(()=>{let e=e=>!zt(e,u),t;if(ut){t=lt.find(e);for(let n=ot+1;!t&&n<H.length;n++){let r=nt.get(H[n].sha)?.find(e);r&&(t=r,Tt(H[n].sha))}}else if(Qe){let n=Math.max(Ue,0),r=[...Me.slice(n),...Me.slice(0,n)];for(let n of r){let r=n.files.map(e=>e.file).find(e);if(r){t=r,n!==We&&Ct(Me.indexOf(n));break}}}else t=Oe.find(e);t&&(Pt(t.path),D(e=>{if(!e.has(t.path))return e;let n=new Set(e);return n.delete(t.path),n}),C(t.hunks[0]?.id??null),T(t.hunks.length===0?t.path:null),Ln(t.path))},[Oe,u,Pt,Qe,Ue,We,Me,Ct,Ln,ut,lt,ot,H,nt,Tt]),Kn=(0,x.useCallback)(e=>{if(cn(e.threadId),e.gone)rn(e=>e+1);else if(e.layerId!==void 0){be(`layers`),Ye(`steps`);let t=ke.findIndex(t=>t.id===e.layerId);t!==-1&&ts(ke[t])!==Ne&&Ct(t)}else e.path?(jt.current=e.path,ut&&!lt.some(t=>t.path===e.path)&&be(`files`),Et(e.path),Pt(e.path),D(t=>{if(!t.has(e.path))return t;let n=new Set(t);return n.delete(e.path),n})):(Qe&&!Be&&(ze?wt():be(`files`)),on(e.threadId),tn(e=>e+1));let t=n=>{jt.current=null;let r=document.querySelector(`[data-thread-id="${e.threadId}"]`);r?Aa(r,Of):n>0&&requestAnimationFrame(()=>t(n-1))};requestAnimationFrame(()=>t(30))},[Pt,Et,ke,Ne,Ct,Qe,Be,ze,wt,ut,lt]),qn=(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}:{}}),[]),Jn=(0,x.useCallback)(e=>{let t=Vt.find(t=>t.thread.id===e);if(t){Kn(qn(t));return}let n=Jt.find(t=>t.thread.id===e);n&&Kn(qn(n,!0))},[Vt,Jt,Kn,qn]),Yn=uf({threads:I?.threads,title:I?.title,onOpenThread:Jn}),Xn=(0,x.useRef)(null),Zn=(0,x.useMemo)(()=>{if(!e)return Sl;let t=Xn.current;return t&&t.version===e.version?Sl:Cl(t,e,mf(df(e)))},[e]);(0,x.useEffect)(()=>{e&&(Xn.current=e)},[e]),(0,x.useEffect)(()=>{e&&Zn.changedViewedHunkIds.size!==0&&hn(t=>{let n=new Set(t);for(let t of e.files)t.hunks.some(e=>Zn.changedViewedHunkIds.has(e.id))&&n.add(t.path);return n.size===t.size?t:n})},[e,Zn]);let Qn=(0,x.useMemo)(()=>ft.flatMap(e=>e.hunks.map(t=>({id:t.id,path:e.path}))),[ft]);(0,x.useEffect)(()=>{b&&!Qn.some(e=>e.id===b)&&C(null)},[Qn,b]);let $n=Qn.find(e=>e.id===b)?.path??w,er=(0,x.useCallback)(e=>{if(Qn.length===0)return;let t=Qn.findIndex(e=>e.id===b),n=0;if(t!==-1){if(e===`next-hunk`)n=Math.min(t+1,Qn.length-1);else if(e===`prev-hunk`)n=Math.max(t-1,0);else if(e===`next-file`){let e=Qn[t].path,r=Qn.findIndex((n,r)=>r>t&&n.path!==e);n=r===-1?t:r}else{let e=Qn[t].path,r=[...Qn.slice(0,t)].reverse().find(t=>t.path!==e);n=r?Qn.findIndex(e=>e.path===r.path):t}}let{id:r,path:i}=Qn[n];C(r),T(null),Pt(i),requestAnimationFrame(()=>{document.querySelector(`[data-hunk-id="${r}"]`)?.scrollIntoView({behavior:`instant`,block:`center`})})},[Qn,b,Pt]);(0,x.useEffect)(()=>{let e=e=>{if(e.metaKey||e.ctrlKey||e.altKey||zd(e.target))return;let t=Rd(e.key,e.shiftKey);if(t){if(e.preventDefault(),t===`toggle-viewed`)$n&&Pn($n);else if(t===`comment`)b&&ne(b);else if(t===`toggle-view-mode`)y(e=>e===`unified`?`split`:`unified`);else if(t===`toggle-nav`)An();else if(t===`focus-search`)be(`files`),k(!1),Se(e=>e+1);else if(t===`next-unreviewed`)Gn();else if(t===`shortcuts`)de(e=>!e);else if(t===`toggle-fold`)$n&&jn($n);else if(t===`hide-reviewed`)V.setHideReviewed(!V.hideReviewed);else if((t===`next-layer`||t===`prev-layer`)&&Ze){let e=ot+(t===`next-layer`?1:-1);ot>=0&&e>=0&&e<H.length&&Tt(H[e].sha)}else if(t===`next-layer`||t===`prev-layer`){if(!Qe)return;let e=cs(Me,Ue,t===`next-layer`?1:-1,pt);e===null?t===`prev-layer`&&ze&&!Be&&wt():Ct(e)}else if(t===`next-decision`){let e=$e?.decisions;if(!e||e.length===0)return;let t=Fe===null?0:(Fe+1)%e.length;Ie(t);let n=e[t].places.find(e=>e.hunkId);n?zn(n.at.path,n.at.line??null):document.querySelector(`.reading-pane`)?.scrollTo({top:0})}else er(t)}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[er,b,$n,Pn,Qn,An,Gn,jn,V.hideReviewed,V.setHideReviewed,Qe,Me,Ue,pt,Ct,wt,Le,Be,$e,Fe,zn,Ze,ot,H,Tt]);let tr=ke.filter(e=>!e.derived).length,nr=(0,x.useMemo)(()=>H.filter(e=>e.sha!==gt),[H]),rr=(0,x.useMemo)(()=>{if(!Ze||!U)return;let e=lt??kf,t=U.sha===gt,n=nr.indexOf(U)+1,r=[U.short,U.author,U.at&&wa(U.at)].filter(Boolean).join(` · `);return{id:null,kicker:t?`Not committed yet`:`Commit ${n} of ${nr.length} · ${r}`,title:U.subject,mechanical:!1,...t?{summary:`Edits in the working tree that no commit holds yet.`}:U.body?{summary:U.body}:{},missing:[],listed:e.length,hidden:0,onJump:zn,notes:new Map,knownPaths:e.map(e=>e.path)}},[Ze,U,nr,lt,zn]),ir=(0,x.useMemo)(()=>{if(!Ze||!U)return;let e=Ja(lt??kf,u),t=U.sha===gt,n=lt===void 0?`reading…`:e.files===0?`nothing here`:e.doneFiles===e.files?`read`:`${e.files-e.doneFiles} left`,r=e=>{let t=H[e];return t?{title:t.subject,onGo:()=>Tt(t.sha)}:null};return{text:`${t?`uncommitted`:`commit ${nr.indexOf(U)+1} / ${nr.length}`} · ${e.files} ${e.files===1?`file`:`files`} · ${n}`,title:`${e.doneFiles} of ${e.files} files in this commit marked reviewed`,progress:e.marks===0?0:e.doneMarks/e.marks,stats:U.stats,prev:r(ot-1),next:r(ot+1),noun:`commit`}},[Ze,U,lt,u,H,ot,nr,Tt]),ar=(0,x.useMemo)(()=>{let e=new Map;for(let t of Rt){if(t.anchor.kind!==`hunk`&&t.anchor.kind!==`file`)continue;let n=e.get(t.anchor.path);n?n.push(t):e.set(t.anchor.path,[t])}return e},[Rt]),or=(0,x.useMemo)(()=>{let e=$e;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:Fe,onOpenDecision:Ie}:{},kicker:e.derived?`Outside the outline`:`Layer ${e.number} of ${tr}`,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:zn,notes:t,knownPaths:Oe.map(e=>e.path)}},[$e,tr,zn,Oe,Fe]),sr=(0,x.useMemo)(()=>{let e=e=>cs(Me,Ue,e,pt),t=e=>e===null?null:{title:ke[e].title,onGo:()=>Ct(e)};if(Qe&&Be)return{text:Re?`overview · the description`:`overview · the guide`,title:Re?`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=$e;if(!n)return;let r=as(n,u),i=n.derived?`since your review`:`layer ${n.number} / ${tr}`,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:os(n),prev:o===null?ze?{title:`Overview`,onGo:wt}:null:t(o),next:t(e(1))}},[Qe,Be,$e,u,ke,Me,Ue,pt,tr,Ct,wt,Re,ze]),cr=r===`waiting`?`noagent`:l??`quiet`;return t?(0,S.jsxs)(`div`,{className:`center-note`,children:[(0,S.jsx)(Eo,{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)(At,{}),(0,S.jsx)(W,{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:Ce,children:(0,S.jsxs)(`div`,{className:`layout`,children:[(0,S.jsx)(qo,{changeset:e,agent:{presence:r,reason:i,since:a,activity:Gt,onInvite:()=>B(!0),batch:Ut,suggestion:!Ae&&l===null&&I?.layersSuggested?{reason:I.layersSuggested.reason,onOutline:Mt}:void 0,monitorOpen:Kt,onOpenMonitor:qt,monitorPanel:(0,S.jsx)(el,{stillTo:Ht.stillTo,back:Ht.back,onOpen:e=>{qt(!1),Kn(qn(e))},onClose:()=>qt(!1)})},review:{openComments:fn,publicDrafts:pn,onFinishReview:()=>se(!0)},settings:{theme:fe,onSetTheme:pe,critter:me,onSetCritter:he,...ge.status?{onShowPrivacy:()=>ve(!0)}:{},onShowShortcuts:()=>de(!0)}}),(0,S.jsxs)(`div`,{ref:P,className:`body${O?` nav-hidden`:``}${M?` rail-dragging`:``}`,style:{"--rail-w":`${F.current}px`},children:[(0,S.jsx)(Es,{tab:ye,onSetTab:be,fileCount:e.files.length,wantsYou:Zt,threadCount:Qt,settledCount:$t,layerCount:Ae?tr:null,layersSuggested:I?.layersSuggested!==void 0,layers:(0,S.jsxs)(S.Fragment,{children:[qe&&(0,S.jsx)(ws,{source:Xe,onPick:Ye,stepCount:Ae?tr:null,commitCount:nr.length}),Xe===`commits`?(0,S.jsx)(Xa,{commits:H,filesBySha:nt,activeSha:U?.sha??null,onPick:Tt,viewed:u,threads:ar,loading:Ke.isLoading,error:Ke.error?Ke.error.message:void 0,selectedPath:$n,onPickFile:Rn,onToggleFileViewed:Pn,onMarkCommitFiles:Fn,onClearCommitFiles:In}):Ae?(0,S.jsx)(Cs,{layers:Me,activeIndex:Ue,onPick:Ct,viewed:u,guide:Le,description:Re,overviewActive:Be,onOpenGuide:ze?wt:void 0,threads:Xt,attention:Yt,changed:De.changed,selectedPath:$n,onPickFile:Rn,onToggleFileViewed:Pn,onMarkFiles:Un,onClearFiles:Wn,onAskFile:e=>{Pt(e),R(e)},onRefresh:we?Mt:void 0,request:we?l:null}):(0,S.jsx)(Ts,{state:cr,onOutline:Mt,onInvite:()=>B(!0)})]}),files:(0,S.jsx)(Ka,{files:Oe,viewed:u,selectedPath:$n,onPickFile:Rn,onToggleFileViewed:Pn,onMarkFiles:Un,onClearFiles:Wn,onAskFile:e=>{Pt(e),R(e)},threads:Xt,attention:Yt,changed:De.changed,query:V.query,onQuery:V.setQuery,focusTick:xe,hideReviewed:V.hideReviewed,onHideReviewed:V.setHideReviewed,hideTests:V.hideTests,onHideTests:V.setHideTests,onlyChanged:Te,onOnlyChanged:Ee}),threads:(0,S.jsx)(jd,{items:Vt,pastItems:Jt,pr:Ce!==null,selectedThreadId:sn,totalThreads:I?.threads.length??0,onOpen:e=>Kn(qn(e,e.gone===!0)),onResolve:L.resolve,onReopen:L.reopen,onDelete:L.remove,onClearAll:()=>le(!0)})}),(0,S.jsx)(`div`,{className:`rail-resize`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize file list`,"aria-valuemin":bf,"aria-valuemax":xf,"aria-valuenow":A,tabIndex:0,"data-tip":`Drag to resize · double-click (or Home) to reset`,onPointerDown:Dn,onDoubleClick:On,onKeyDown:e=>{e.key===`ArrowLeft`?(e.preventDefault(),En(F.current-16)):e.key===`ArrowRight`?(e.preventDefault(),En(F.current+16)):(e.key===`Home`||e.key===`Enter`)&&(e.preventDefault(),On())}}),(0,S.jsx)(Wu,{files:Ft,delta:Zn,landed:bn,sinceReview:De.changedHunkIds,hasMore:ht<ft.length,onLoadMore:St,layer:Ze?rr:or,overview:!ut&&Qe&&Be,controls:{layer:Ze?ir:sr,navHidden:O,onToggleNav:An,left:_.total-_.viewed,total:_.total,hunksRead:g.viewed,hunksTotal:g.total,hunkAt:b?Qn.findIndex(e=>e.id===b)+1:0,hunkCount:Qn.length,query:V.query,onClearQuery:()=>V.setQuery(``),hiddenQuery:Qe||ut?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:ut?0:Qe?$e?.hidden??0:V.hiddenTests,hiddenReviewed:Qe||ut?0:V.hiddenReviewed,hiddenUnchanged:Qe||ut?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&&Ee(!1)},onFinish:()=>se(!0),stats:e.stats,unsent:fn,viewMode:v,onSetViewMode:y,allCollapsed:E.size>=e.files.length&&e.files.length>0,onToggleCollapseAll:()=>D(t=>t.size>=e.files.length?new Set:new Set(e.files.map(e=>e.path)))},viewed:u,onToggleFileViewed:Pn,selectedId:b,onSelect:C,viewMode:v,collapsed:E,onToggleCollapsed:jn,comments:Hn})]}),oe&&(e.pr?(0,S.jsx)(Ju,{coverage:_n,presence:r,onFinish:Tn,onInvite:()=>{se(!1),B(!0)},onClose:()=>se(!1)}):(0,S.jsx)($a,{coverage:_n,presence:r,checkOff:xn,onResolve:Cn,onReopen:wn,onFinish:Tn,onInvite:()=>{se(!1),B(!0)},onClose:()=>se(!1)})),ce&&(0,S.jsx)(It,{total:I?.threads.length??0,past:G.length,outdated:G.filter(e=>e.github?.outdated===!0).length,onClear:vn,onClose:()=>le(!1)}),(0,S.jsx)(Nt,{notices:Yn.notices,onOpen:Yn.open,onDismiss:Yn.dismiss,onClear:Yn.clear,onOpenMonitor:()=>qt(!0)}),ge.status&&(0,S.jsx)(vd,{status:ge.status,onShown:ge.markShown,onAcknowledge:ge.acknowledge}),_e&&ge.status&&(0,S.jsx)(il,{status:ge.status,onSetEnabled:ge.setEnabled,onClose:()=>ve(!1)}),ue&&(0,S.jsx)(Ku,{onClose:()=>de(!1)}),z&&(0,S.jsx)(Jo,{presence:r,reason:i,onClose:()=>B(!1)}),(0,S.jsx)(id,{files:e?.files??kf,onJump:Bn})]})}):null}function Ff(){return(0,S.jsxs)(T,{client:_f,children:[(0,S.jsx)(At,{}),(0,S.jsx)(Pf,{})]})}var If=400,Lf=300;function Rf(){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<Lf;l(),n=e,t||o?c():i=setTimeout(c,If)},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`})}Yd(qd()),(0,at.createRoot)(document.getElementById(`root`)).render((0,S.jsxs)(x.StrictMode,{children:[(0,S.jsx)(Ff,{}),(0,S.jsx)(Rf,{})]}));export{u as a,s as i,gr as n,l as o,o as r,X as t};
|
|
91
|
+
`,1)[0].trim()})}return n}function rf(e,t){return e>0?`(${e}) ${t}`:t}function af(e,t,n=!1){return e?n?`dev · ${e}`:e:t}var of=8e3;function sf(e,t){let n=0;return e.map(e=>e.kind===`guide`?e:{...e,expiresAt:t+350*n++})}function cf(e,t){let n=-1/0;for(let t of e)t.expiresAt!==null&&t.expiresAt>n&&(n=t.expiresAt);return Math.max(t+of,n+350)}function lf(e){let t=document;if(typeof t.startViewTransition!=`function`){e();return}let n=t.startViewTransition(()=>(0,Pt.flushSync)(e));n.ready.catch(()=>{}),n.finished.catch(()=>{})}function uf({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)(ro()),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=rf(l.current,af(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(ef(e));return}let t=nf(e,a.current);for(let t of ef(e))a.current.add(t);if(t.length===0)return;if(document.hasFocus()){let e=Date.now(),n=t.map(e=>({...e,expiresAt:null}));lf(()=>i(t=>[...t,...sf(n,cf(t,e))]));return}l.current+=t.length,d();let n=t.map(e=>({...e,expiresAt:null}));lf(()=>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()+of;i(t=>sf(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();lf(()=>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)(()=>lf(()=>i([])),[]),p=(0,x.useCallback)(e=>{lf(()=>i(t=>t.filter(t=>t.key!==e.key)))},[]);return{notices:r,open:(0,x.useCallback)(e=>{lf(()=>i(t=>t.filter(t=>t.key!==e.key))),u.current(e.threadId)},[]),dismiss:p,clear:f}}function df(e){return`diffo:viewed:${e.repo.path}:${pf(e)}`}function ff(e){return`diffo:viewed:${e.repo.name}:${pf(e)}`}function pf(e){return e.spec.kind===`working-tree`?`working-tree`:`branch:${e.spec.base}`}function mf(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 hf(e,t){try{localStorage.setItem(e,JSON.stringify([...t]))}catch{}}function gf(e){let t=e?df(e):null,n=e?ff(e):null,[r,i]=(0,x.useState)(new Set),[a,o]=(0,x.useState)(!1);(0,x.useEffect)(()=>{if(!t)return;let e=mf(t);if(e.size===0&&n!==null&&n!==t){let e=mf(n);if(e.size>0){hf(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=Lt(r),a=i.every(e=>n.has(e));for(let e of i)a?n.delete(e):n.add(e);return t&&hf(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 Lt(t))r?i.add(e):i.delete(e);return t&&hf(t,i),i})},[e,t]),l=(0,x.useCallback)((e,n)=>{i(r=>{let i=new Set(r);for(let t of e)n?i.add(t):i.delete(t);return t&&hf(t,i),i})},[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]),setMarks:l,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++,zt(i,r)&&n++;return{viewed:n,total:t}},[e,r])}}var _f=new Ge,vf=264,yf=800,bf=200,xf=520,Sf=e=>Math.min(xf,Math.max(bf,e)),Cf=12,wf=`overview`,Tf=16,Ef=new Set,Df=new Map;function Of(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 kf=[],Af=[];function jf(){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)(Ef),[d,f]=(0,x.useState)(Df),[p,m]=(0,x.useState)(Ef);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`)):Ef),f(r!==`waiting`&&Array.isArray(t.queued)?new Map(t.queued.filter(e=>typeof e==`string`).map((e,t)=>[e,t+1])):Df),m(r!==`waiting`&&Array.isArray(t.answered)?new Set(t.answered.filter(e=>typeof e==`string`)):Ef))}catch{}}),t.onopen=()=>{e.invalidateQueries({queryKey:[`review`]}),e.invalidateQueries({queryKey:[`changeset`]})},t.onerror=()=>{n(`waiting`),o(`disconnected`),c(null),u(Ef),f(Df),m(Ef),i(null)},()=>t.close()},[e]),{presence:t,reason:a,since:s,workingOn:l,queuedOn:d,answeredOn:p,layersRequest:r}}function Mf(e,t,n){let[r,i]=(0,x.useState)(null),a=(0,x.useRef)(Ef);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(Hs(s.anchor))},[e,t,n]),r}function Nf(){let e=w();return(0,x.useMemo)(()=>{let t=()=>e.invalidateQueries({queryKey:[`review`]});return{create:async(e,n,r,i)=>{let a=await Dt.createThread(e,n,r,i);return await t(),a},reply:(e,n,r)=>Dt.reply(e,n,r).then(t),edit:(e,n,r,i)=>Dt.editMessage(e,n,r,i).then(t),send:async e=>{let{prompt:n,delivered:r,presence:i}=await Dt.send(e);if(r||i!==`waiting`)return await t(),{delivered:!0};let a=await Ot(n);return await t(),{delivered:!1,copied:a,prompt:n}},resolve:e=>Dt.setState(e,`resolved`).then(t),reopen:e=>Dt.setState(e,`open`).then(t),remove:e=>Dt.remove(e).then(t),dismissPrComment:(e,n)=>Dt.dismissPrComment(e,n).then(t)}},[e])}function Pf(){let{data:e,isLoading:t,error:n}=_t(),{presence:r,reason:i,since:a,workingOn:o,queuedOn:s,answeredOn:c,layersRequest:l}=jf(),{viewed:u,loaded:d,toggleFile:f,markFiles:p,clearFiles:m,setMarks:h,progress:g,fileProgress:_}=gf(e),[v,y]=(0,x.useState)(`unified`),[b,C]=(0,x.useState)(null),[w,T]=(0,x.useState)(null),[E,D]=(0,x.useState)(new Set),[O,k]=(0,x.useState)(()=>{let e=localStorage.getItem(`diffo:ui:navHidden`);return e===null?window.innerWidth<yf:e===`1`}),[A,j]=(0,x.useState)(()=>{let e=Number(localStorage.getItem(`diffo:ui:railWidth`));return e>0?Sf(e):vf}),[M,N]=(0,x.useState)(!1),P=(0,x.useRef)(null),F=(0,x.useRef)(A);F.current=M?F.current:A;let ee=(0,x.useRef)(null);(0,x.useEffect)(()=>()=>ee.current?.(),[]);let{data:I}=bt(),L=Nf(),[te,ne]=(0,x.useState)(null),[re,R]=(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),[z,B]=(0,x.useState)(!1),[fe,pe]=Qd(),[me,he]=Ld(),ge=Wd(),[_e,ve]=(0,x.useState)(!1),[ye,be]=(0,x.useState)(`files`),[xe,Se]=(0,x.useState)(0),Ce=e?.pr??null,we=r!==`waiting`,[Te,Ee]=(0,x.useState)(!1),De=(0,x.useMemo)(()=>Ud(e,I?.lastFinish,u),[e,I,u]),Oe=(0,x.useMemo)(()=>Ua(e?.files??[]),[e]),V=Ra(Oe,(0,x.useCallback)(e=>zt(e,u),[u]),{on:Te,changed:De.changed,set:Ee}),ke=(0,x.useMemo)(()=>$o(I?.layers,Oe),[I?.layers,Oe]),Ae=ke.length>0,je=(0,x.useMemo)(()=>is(ke),[ke]),Me=(0,x.useMemo)(()=>V.hideTests?es(ke,e=>Ma(e.path)&&!V.pinned.has(e.path)):ke,[ke,V.hideTests,V.pinned]),[Ne,Pe]=(0,x.useState)(null),[Fe,Ie]=(0,x.useState)(null);(0,x.useEffect)(()=>Ie(null),[Ne]);let Le=(0,x.useMemo)(()=>ns(I?.threads??[]),[I?.threads]),Re=(0,x.useMemo)(()=>Ce?rs(I?.threads??[]):void 0,[Ce,I?.threads]),ze=Le!==void 0||Re!==void 0,Be=Ae&&Ne===wf&&ze,Ve=ke.findIndex(e=>ts(e)===Ne),He=(0,x.useMemo)(()=>ke.every(e=>e.files.every(e=>!zt(e.file,u))),[ke,u]),Ue=Ae?Be?-1:Ve===-1?ls(Me,u):Ve:-1,We=Ae&&Ue>=0?Me[Ue]:void 0,Ge=Ae&&Ue>=0?ke[Ue]:void 0,Ke=vt(e?.version,e?.spec.kind===`branch`),H=Ke.data?.commits??Af,qe=H.length>0,[Je,Ye]=(0,x.useState)(null),Xe=qe&&Je===`commits`?`commits`:`steps`,Ze=ye===`layers`&&Xe===`commits`,Qe=Ae&&ye===`layers`&&!Ze,$e=Qe?We:void 0;(0,x.useEffect)(()=>{Ae&&d&&Ve===-1&&!Be&&Pe(ze&&He&&Ne===null?wf:ts(ke[Ue]))},[Ae,d,Ve,Be,ke,Ue,ze,He,Ne]);let[et,tt]=(0,x.useState)(!1);(0,x.useEffect)(()=>{Ze&&tt(!0)},[Ze]);let nt=yt((0,x.useMemo)(()=>et?H.map(e=>e.sha):[],[et,H]),e?.version),[rt,it]=(0,x.useState)(null),at=H.findIndex(e=>e.sha===rt),ot=at===-1?H.length===0?-1:Math.max(0,H.findIndex(e=>{let t=nt.get(e.sha);return t===void 0||t.some(e=>!zt(e,u))})):at,U=ot>=0?H[ot]:void 0,ct=U?nt.get(U.sha):void 0,lt=(0,x.useMemo)(()=>ct?Ua(ct):void 0,[ct]),ut=Ze&<!==void 0;(0,x.useEffect)(()=>{Ze&&d&&at===-1&&ut&&U&&it(U.sha)},[Ze,d,at,ut,U]);let ft=(0,x.useMemo)(()=>Ze?lt??kf:Qe&&Be?[]:$e?$e.files.map(e=>e.file):V.files,[Ze,lt,Qe,Be,$e,V.files]),pt=(0,x.useCallback)(e=>e.files.length===0,[]),[ht,xt]=(0,x.useState)(Cf),St=(0,x.useCallback)(()=>xt(e=>e+Cf),[]),Ct=(0,x.useCallback)(e=>{let t=ke[e];t&&(Pe(ts(t)),C(null),T(null),xt(Cf),requestAnimationFrame(()=>{document.querySelector(`.reading-pane`)?.scrollTo({top:0})}))},[ke]),wt=(0,x.useCallback)(()=>{Pe(wf),C(null),T(null),requestAnimationFrame(()=>{document.querySelector(`.reading-pane`)?.scrollTo({top:0})})},[]),Tt=(0,x.useCallback)(e=>{it(e),C(null),T(null),xt(Cf),requestAnimationFrame(()=>{document.querySelector(`.reading-pane`)?.scrollTo({top:0})})},[]),Et=(0,x.useCallback)(e=>{if(!Qe||Ge?.files.some(t=>t.file.path===e))return;let t=je.get(e);t&&Ct(ke.indexOf(t))},[Qe,Ge,je,ke,Ct]),Ot=$e?.kind===`mechanical`?ts($e):null,kt=(0,x.useRef)($e);kt.current=$e;let jt=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(Ot===null)return;let e=jt.current,t=(kt.current?.files??[]).map(e=>e.file.path).filter(t=>t!==e);D(e=>new Set([...e,...t]))},[Ot]),(0,x.useEffect)(()=>{Ae&&be(`layers`)},[Ae]);let Mt=(0,x.useCallback)(()=>{Dt.requestLayers().catch(()=>{})},[]),Pt=(0,x.useCallback)(e=>{V.pin(e);let t=Qe?Ge?.files.some(t=>t.file.path===e)?Ge:je.get(e):void 0,n=ut?ft.findIndex(t=>t.path===e):t?t.files.findIndex(t=>t.file.path===e):Oe.findIndex(t=>t.path===e);n>=0&&xt(e=>Math.max(e,n+1))},[Oe,V.pin,Qe,Ge,je,ut,ft]),Ft=(0,x.useMemo)(()=>ft.slice(0,ht),[ft,ht]),{active:Rt,past:G}=(0,x.useMemo)(()=>{let t=mt(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]),Bt=(0,x.useMemo)(()=>ut?nu(lt,e?.files??kf,Rt):eu(e?.files??[],Rt),[e,Rt,ut,lt]),Vt=(0,x.useMemo)(()=>Vs(Rt,o,s),[Rt,o,s]),Ht=(0,x.useMemo)(()=>({stillTo:Vt.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:Vt.filter(e=>c.has(e.thread.id))}),[Vt,c]),Ut=(0,x.useMemo)(()=>({segments:[...Ht.back.map(()=>`done`),...Ht.stillTo.map(e=>e.working===!0?`now`:`wait`)],done:Ht.back.length}),[Ht]),Wt=Mf(Vt,c,r),Gt=r===`working`?Us(Ht.stillTo,Wt)??(l===`outlining`?`outlining layers`:null):null,[Kt,qt]=(0,x.useState)(!1);(0,x.useEffect)(()=>{Kt&&Ht.stillTo.length===0&&Ht.back.length===0&&qt(!1)},[Kt,Ht]),(0,x.useEffect)(()=>{Te&&De.changed.size===0&&Ee(!1)},[Te,De]);let Jt=(0,x.useMemo)(()=>Vs(G),[G]),Yt=(0,x.useMemo)(()=>qs(Vt),[Vt]),Xt=(0,x.useMemo)(()=>ru(e?.files??[],Bt),[e,Bt]),Zt=Gs(Vt)+Gs(Jt),Qt=Ks(Vt)+Ks(Jt),$t=Vt.length+Jt.length-Qt,[en,tn]=(0,x.useState)(0),[nn,rn]=(0,x.useState)(0),[an,on]=(0,x.useState)(null),[sn,cn]=(0,x.useState)(null),ln=ut?U?.sha??null:null,un=(0,x.useMemo)(()=>ln===null?L:{...L,create:(e,t,n,r)=>L.create(e,t,n,{...r,commit:ln})},[L,ln]),dn=(0,x.useMemo)(()=>({partition:Bt,past:G,actions:un,agentConnected:we,workingOn:o,queuedOn:s,composeHunkId:te,onComposeHandled:()=>ne(null),composeFilePath:re,onComposeFileHandled:()=>R(null),changesetComposerOpen:ie,onOpenChangesetComposer:()=>ae(!0),onCloseChangesetComposer:()=>ae(!1),revealNotesTick:en,revealPastTick:nn,revealThreadId:an}),[Bt,G,un,we,o,s,te,re,ie,en,nn,an]),fn=(0,x.useMemo)(()=>{let e=0;for(let t of Rt)As(t)&&e++;return e},[Rt]),pn=(0,x.useMemo)(()=>Rt.filter(st).length+G.filter(st).length,[Rt,G]),[mn,hn]=(0,x.useState)(new Set),gn=(0,x.useMemo)(()=>{let e=new Set;for(let t of Rt)dt(t)||(t.anchor.kind===`hunk`||t.anchor.kind===`file`)&&e.add(t.anchor.path);return e},[Rt]),_n=(0,x.useMemo)(()=>{let e=Oe.filter(e=>!zt(e,u)),t=e.filter(e=>mn.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:g.viewed,totalHunks:g.total,viewedFiles:_.viewed,totalFiles:_.total,changedFiles:t,commentedUnread:i.filter(e=>gn.has(e.path)).map(e=>e.path),filteredOut:i.filter(e=>!gn.has(e.path)&&r.has(e.path)).map(e=>e.path),skippedFiles:i.filter(e=>!gn.has(e.path)&&!r.has(e.path)).map(e=>e.path)}},[Oe,g,_,u,mn,gn,V.scope.excludedPaths]),vn=(0,x.useCallback)(async()=>{await Dt.clear(),await _f.invalidateQueries({queryKey:[`review`]})},[]),yn=(0,x.useCallback)(()=>{_f.setQueryData([`review`],e=>e&&{...e,landed:void 0}),Dt.dismissLanded().then(()=>_f.invalidateQueries({queryKey:[`review`]}))},[]),bn=(0,x.useMemo)(()=>{if(I?.landed)return{sha:I.landed.sha,subject:I.landed.subject,threads:I.threads.length,onClear:vn,onDismiss:yn}},[I,vn,yn]),xn=(0,x.useMemo)(()=>{let e=e=>e.turn===`yours`||e.turn===`unanswered`;return[...Vt.filter(e),...Jt.filter(e).map(e=>({...e,gone:!0}))]},[Vt,Jt]),Sn=(0,x.useCallback)(async()=>{await _f.invalidateQueries({queryKey:[`review`]}),await _f.invalidateQueries({queryKey:[`finish-preview`]})},[]),Cn=(0,x.useCallback)(e=>Dt.setState(e,`resolved`).then(Sn),[Sn]),wn=(0,x.useCallback)(e=>Dt.setState(e,`open`).then(Sn),[Sn]),Tn=(0,x.useCallback)(async(e,t)=>{let n={..._n,...t&&t.note.trim()!==``?{note:t.note.trim()}:{}},{prompt:r,delivered:i,presence:a,public:o}=await Dt.finish(n,e,t?.event);await _f.invalidateQueries({queryKey:[`review`]}),await _f.invalidateQueries({queryKey:[`changeset`]}),await _f.invalidateQueries({queryKey:[`finish-preview`]});let s=i||a!==`waiting`;return e&&s&&fn>0&&!o?.failed&&qt(!0),{prompt:r,delivered:s,...o?{public:o}:{}}},[_n,fn]),En=(0,x.useCallback)(e=>{let t=Sf(e);F.current=t,j(t),localStorage.setItem(`diffo:ui:railWidth`,String(t))},[]),Dn=(0,x.useCallback)(e=>{if(e.button!==0)return;e.preventDefault();let t=e.clientX,n=F.current,r=n,i=e=>{r=Sf(n+e.clientX-t),F.current=r,P.current?.style.setProperty(`--rail-w`,`${r}px`)},a=()=>{ee.current?.(),ee.current=null,N(!1),En(r)};ee.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`,N(!0)},[En]),On=(0,x.useCallback)(()=>En(vf),[En]),kn=(0,x.useRef)(localStorage.getItem(`diffo:ui:navHidden`)!==null),An=(0,x.useCallback)(()=>{kn.current=!0,k(e=>!e)},[]);(0,x.useEffect)(()=>{kn.current&&localStorage.setItem(`diffo:ui:navHidden`,O?`1`:`0`)},[O]);let K=(0,x.useRef)(!1);(0,x.useEffect)(()=>{if(K.current||!d||!e)return;K.current=!0;let t=e.files.filter(e=>zt(e,u)).map(e=>e.path);t.length>0&&D(e=>new Set([...e,...t]))},[d,e,u]);let jn=(0,x.useCallback)(e=>{D(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Mn=(0,x.useRef)(null),Nn=(0,x.useCallback)(e=>{let t=document.querySelector(`.reading-pane`),n=document.getElementById(ka(e));if(!t||!n)return;let r=t.getBoundingClientRect().top,i=n.getBoundingClientRect(),a=i.top-r+t.scrollTop;i.bottom<=r?Mn.current=t.scrollTop-(i.height+Tf):i.top<=r&&(Mn.current=a)},[]);(0,x.useLayoutEffect)(()=>{let e=Mn.current;if(e===null)return;Mn.current=null;let t=document.querySelector(`.reading-pane`);t&&(t.scrollTop=Math.max(0,e))});let Pn=(0,x.useCallback)(t=>{let n=ut?lt.find(e=>e.path===t):void 0,r=n??e?.files.find(e=>e.path===t);if(!r)return;let i=zt(r,u);!i&&V.hideReviewed&&!n&&(Nn(t),V.unpin(t)),n?h(Lt(n),!i):f(t),D(e=>{let n=new Set(e);return i?n.delete(t):n.add(t),n})},[e,f,u,V.hideReviewed,V.unpin,Nn,ut,lt,h]),Fn=(0,x.useCallback)(e=>{h(e.flatMap(Lt),!0),D(t=>new Set([...t,...e.map(e=>e.path)]))},[h]),In=(0,x.useCallback)(e=>{h(e.flatMap(Lt),!1),D(t=>{let n=new Set(t);for(let t of e)n.delete(t.path);return n})},[h]),Ln=(0,x.useCallback)(e=>{let t=n=>{let r=document.getElementById(ka(e));r?Aa(r,Of):n>0&&requestAnimationFrame(()=>t(n-1))};requestAnimationFrame(()=>t(30))},[]),Rn=(0,x.useCallback)(e=>{Et(e),Pt(e),D(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n}),Ln(e)},[Pt,Et,Ln]),zn=(0,x.useCallback)(({path:t,side:n,line:r})=>{let i=e?.files.find(e=>e.path===t);if(!i)return;Et(t),Pt(t),D(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){Ln(t);return}C(a.id),T(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?Aa(n,Of,`center`):t>0&&requestAnimationFrame(()=>e(t-1))};e(30)})},[e,Et,Pt,Ln]),Bn=(0,x.useCallback)((t,n)=>{e?.files.some(e=>e.path===t)&&(n===null?Rn(t):zn({path:t,side:`head`,line:n}))},[e,Rn,zn]),Vn=(0,x.useMemo)(()=>({paths:Oe.map(e=>e.path),onJump:Bn}),[Oe,Bn]),Hn=(0,x.useMemo)(()=>({...dn,links:Vn}),[dn,Vn]),Un=(0,x.useCallback)(e=>{p(e);for(let t of e)V.unpin(t);D(t=>new Set([...t,...e]))},[p,V.unpin]),Wn=(0,x.useCallback)(e=>{m(e),D(t=>{let n=new Set(t);for(let t of e)n.delete(t);return n})},[m]),Gn=(0,x.useCallback)(()=>{let e=e=>!zt(e,u),t;if(ut){t=lt.find(e);for(let n=ot+1;!t&&n<H.length;n++){let r=nt.get(H[n].sha)?.find(e);r&&(t=r,Tt(H[n].sha))}}else if(Qe){let n=Math.max(Ue,0),r=[...Me.slice(n),...Me.slice(0,n)];for(let n of r){let r=n.files.map(e=>e.file).find(e);if(r){t=r,n!==We&&Ct(Me.indexOf(n));break}}}else t=Oe.find(e);t&&(Pt(t.path),D(e=>{if(!e.has(t.path))return e;let n=new Set(e);return n.delete(t.path),n}),C(t.hunks[0]?.id??null),T(t.hunks.length===0?t.path:null),Ln(t.path))},[Oe,u,Pt,Qe,Ue,We,Me,Ct,Ln,ut,lt,ot,H,nt,Tt]),Kn=(0,x.useCallback)(e=>{if(cn(e.threadId),e.gone)rn(e=>e+1);else if(e.layerId!==void 0){be(`layers`),Ye(`steps`);let t=ke.findIndex(t=>t.id===e.layerId);t!==-1&&ts(ke[t])!==Ne&&Ct(t)}else e.path?(jt.current=e.path,ut&&!lt.some(t=>t.path===e.path)&&be(`files`),Et(e.path),Pt(e.path),D(t=>{if(!t.has(e.path))return t;let n=new Set(t);return n.delete(e.path),n})):(Qe&&!Be&&(ze?wt():be(`files`)),on(e.threadId),tn(e=>e+1));let t=n=>{jt.current=null;let r=document.querySelector(`[data-thread-id="${e.threadId}"]`);r?Aa(r,Of):n>0&&requestAnimationFrame(()=>t(n-1))};requestAnimationFrame(()=>t(30))},[Pt,Et,ke,Ne,Ct,Qe,Be,ze,wt,ut,lt]),qn=(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}:{}}),[]),Jn=(0,x.useCallback)(e=>{let t=Vt.find(t=>t.thread.id===e);if(t){Kn(qn(t));return}let n=Jt.find(t=>t.thread.id===e);n&&Kn(qn(n,!0))},[Vt,Jt,Kn,qn]),Yn=uf({threads:I?.threads,title:I?.title,onOpenThread:Jn}),Xn=(0,x.useRef)(null),Zn=(0,x.useMemo)(()=>{if(!e)return Sl;let t=Xn.current;return t&&t.version===e.version?Sl:Cl(t,e,mf(df(e)))},[e]);(0,x.useEffect)(()=>{e&&(Xn.current=e)},[e]),(0,x.useEffect)(()=>{e&&Zn.changedViewedHunkIds.size!==0&&hn(t=>{let n=new Set(t);for(let t of e.files)t.hunks.some(e=>Zn.changedViewedHunkIds.has(e.id))&&n.add(t.path);return n.size===t.size?t:n})},[e,Zn]);let Qn=(0,x.useMemo)(()=>ft.flatMap(e=>e.hunks.map(t=>({id:t.id,path:e.path}))),[ft]);(0,x.useEffect)(()=>{b&&!Qn.some(e=>e.id===b)&&C(null)},[Qn,b]);let $n=Qn.find(e=>e.id===b)?.path??w,er=(0,x.useCallback)(e=>{if(Qn.length===0)return;let t=Qn.findIndex(e=>e.id===b),n=0;if(t!==-1){if(e===`next-hunk`)n=Math.min(t+1,Qn.length-1);else if(e===`prev-hunk`)n=Math.max(t-1,0);else if(e===`next-file`){let e=Qn[t].path,r=Qn.findIndex((n,r)=>r>t&&n.path!==e);n=r===-1?t:r}else{let e=Qn[t].path,r=[...Qn.slice(0,t)].reverse().find(t=>t.path!==e);n=r?Qn.findIndex(e=>e.path===r.path):t}}let{id:r,path:i}=Qn[n];C(r),T(null),Pt(i),requestAnimationFrame(()=>{document.querySelector(`[data-hunk-id="${r}"]`)?.scrollIntoView({behavior:`instant`,block:`center`})})},[Qn,b,Pt]);(0,x.useEffect)(()=>{let e=e=>{if(e.metaKey||e.ctrlKey||e.altKey||zd(e.target))return;let t=Rd(e.key,e.shiftKey);if(t){if(e.preventDefault(),t===`toggle-viewed`)$n&&Pn($n);else if(t===`comment`)b&&ne(b);else if(t===`toggle-view-mode`)y(e=>e===`unified`?`split`:`unified`);else if(t===`toggle-nav`)An();else if(t===`focus-search`)be(`files`),k(!1),Se(e=>e+1);else if(t===`next-unreviewed`)Gn();else if(t===`shortcuts`)de(e=>!e);else if(t===`toggle-fold`)$n&&jn($n);else if(t===`hide-reviewed`)V.setHideReviewed(!V.hideReviewed);else if((t===`next-layer`||t===`prev-layer`)&&Ze){let e=ot+(t===`next-layer`?1:-1);ot>=0&&e>=0&&e<H.length&&Tt(H[e].sha)}else if(t===`next-layer`||t===`prev-layer`){if(!Qe)return;let e=cs(Me,Ue,t===`next-layer`?1:-1,pt);e===null?t===`prev-layer`&&ze&&!Be&&wt():Ct(e)}else if(t===`next-decision`){let e=$e?.decisions;if(!e||e.length===0)return;let t=Fe===null?0:(Fe+1)%e.length;Ie(t);let n=e[t].places.find(e=>e.hunkId);n?Bn(n.at.path,n.at.line??null):document.querySelector(`.reading-pane`)?.scrollTo({top:0})}else er(t)}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[er,b,$n,Pn,Qn,An,Gn,jn,V.hideReviewed,V.setHideReviewed,Qe,Me,Ue,pt,Ct,wt,Le,Be,$e,Fe,Bn,Ze,ot,H,Tt]);let tr=ke.filter(e=>!e.derived).length,nr=(0,x.useMemo)(()=>H.filter(e=>e.sha!==gt),[H]),rr=(0,x.useMemo)(()=>{if(!Ze||!U)return;let e=lt??kf,t=U.sha===gt,n=nr.indexOf(U)+1,r=[U.short,U.author,U.at&&wa(U.at)].filter(Boolean).join(` · `);return{id:null,kicker:t?`Not committed yet`:`Commit ${n} of ${nr.length} · ${r}`,title:U.subject,mechanical:!1,...t?{summary:`Edits in the working tree that no commit holds yet.`}:U.body?{summary:U.body}:{},missing:[],listed:e.length,hidden:0,onJump:Bn,notes:new Map,knownPaths:e.map(e=>e.path)}},[Ze,U,nr,lt,Bn]),ir=(0,x.useMemo)(()=>{if(!Ze||!U)return;let e=Ja(lt??kf,u),t=U.sha===gt,n=lt===void 0?`reading…`:e.files===0?`nothing here`:e.doneFiles===e.files?`read`:`${e.files-e.doneFiles} left`,r=e=>{let t=H[e];return t?{title:t.subject,onGo:()=>Tt(t.sha)}:null};return{text:`${t?`uncommitted`:`commit ${nr.indexOf(U)+1} / ${nr.length}`} · ${e.files} ${e.files===1?`file`:`files`} · ${n}`,title:`${e.doneFiles} of ${e.files} files in this commit marked reviewed`,progress:e.marks===0?0:e.doneMarks/e.marks,stats:U.stats,prev:r(ot-1),next:r(ot+1),noun:`commit`}},[Ze,U,lt,u,H,ot,nr,Tt]),ar=(0,x.useMemo)(()=>{let e=new Map;for(let t of Rt){if(t.anchor.kind!==`hunk`&&t.anchor.kind!==`file`)continue;let n=e.get(t.anchor.path);n?n.push(t):e.set(t.anchor.path,[t])}return e},[Rt]),or=(0,x.useMemo)(()=>{let e=$e;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:Fe,onOpenDecision:Ie}:{},kicker:e.derived?`Outside the outline`:`Layer ${e.number} of ${tr}`,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:Bn,notes:t,knownPaths:Oe.map(e=>e.path)}},[$e,tr,Bn,Oe,Fe]),sr=(0,x.useMemo)(()=>{let e=e=>cs(Me,Ue,e,pt),t=e=>e===null?null:{title:ke[e].title,onGo:()=>Ct(e)};if(Qe&&Be)return{text:Re?`overview · the description`:`overview · the guide`,title:Re?`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=$e;if(!n)return;let r=as(n,u),i=n.derived?`since your review`:`layer ${n.number} / ${tr}`,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:os(n),prev:o===null?ze?{title:`Overview`,onGo:wt}:null:t(o),next:t(e(1))}},[Qe,Be,$e,u,ke,Me,Ue,pt,tr,Ct,wt,Re,ze]),cr=r===`waiting`?`noagent`:l??`quiet`;return t?(0,S.jsxs)(`div`,{className:`center-note`,children:[(0,S.jsx)(Eo,{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)(At,{}),(0,S.jsx)(W,{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:Ce,children:(0,S.jsxs)(`div`,{className:`layout`,children:[(0,S.jsx)(qo,{changeset:e,agent:{presence:r,reason:i,since:a,activity:Gt,onInvite:()=>B(!0),batch:Ut,suggestion:!Ae&&l===null&&I?.layersSuggested?{reason:I.layersSuggested.reason,onOutline:Mt}:void 0,monitorOpen:Kt,onOpenMonitor:qt,monitorPanel:(0,S.jsx)(el,{stillTo:Ht.stillTo,back:Ht.back,onOpen:e=>{qt(!1),Kn(qn(e))},onClose:()=>qt(!1)})},review:{openComments:fn,publicDrafts:pn,onFinishReview:()=>se(!0)},settings:{theme:fe,onSetTheme:pe,critter:me,onSetCritter:he,...ge.status?{onShowPrivacy:()=>ve(!0)}:{},onShowShortcuts:()=>de(!0)}}),(0,S.jsxs)(`div`,{ref:P,className:`body${O?` nav-hidden`:``}${M?` rail-dragging`:``}`,style:{"--rail-w":`${F.current}px`},children:[(0,S.jsx)(Es,{tab:ye,onSetTab:be,fileCount:e.files.length,wantsYou:Zt,threadCount:Qt,settledCount:$t,layerCount:Ae?tr:null,layersSuggested:I?.layersSuggested!==void 0,layers:(0,S.jsxs)(S.Fragment,{children:[qe&&(0,S.jsx)(ws,{source:Xe,onPick:Ye,stepCount:Ae?tr:null,commitCount:nr.length}),Xe===`commits`?(0,S.jsx)(Xa,{commits:H,filesBySha:nt,activeSha:U?.sha??null,onPick:Tt,viewed:u,threads:ar,loading:Ke.isLoading,error:Ke.error?Ke.error.message:void 0,selectedPath:$n,onPickFile:Rn,onToggleFileViewed:Pn,onMarkCommitFiles:Fn,onClearCommitFiles:In}):Ae?(0,S.jsx)(Cs,{layers:Me,activeIndex:Ue,onPick:Ct,viewed:u,guide:Le,description:Re,overviewActive:Be,onOpenGuide:ze?wt:void 0,threads:Xt,attention:Yt,changed:De.changed,selectedPath:$n,onPickFile:Rn,onToggleFileViewed:Pn,onMarkFiles:Un,onClearFiles:Wn,onAskFile:e=>{Pt(e),R(e)},onRefresh:we?Mt:void 0,request:we?l:null}):(0,S.jsx)(Ts,{state:cr,onOutline:Mt,onInvite:()=>B(!0)})]}),files:(0,S.jsx)(Ka,{files:Oe,viewed:u,selectedPath:$n,onPickFile:Rn,onToggleFileViewed:Pn,onMarkFiles:Un,onClearFiles:Wn,onAskFile:e=>{Pt(e),R(e)},threads:Xt,attention:Yt,changed:De.changed,query:V.query,onQuery:V.setQuery,focusTick:xe,hideReviewed:V.hideReviewed,onHideReviewed:V.setHideReviewed,hideTests:V.hideTests,onHideTests:V.setHideTests,onlyChanged:Te,onOnlyChanged:Ee}),threads:(0,S.jsx)(jd,{items:Vt,pastItems:Jt,pr:Ce!==null,selectedThreadId:sn,totalThreads:I?.threads.length??0,onOpen:e=>Kn(qn(e,e.gone===!0)),onResolve:L.resolve,onReopen:L.reopen,onDelete:L.remove,onClearAll:()=>le(!0)})}),(0,S.jsx)(`div`,{className:`rail-resize`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize file list`,"aria-valuemin":bf,"aria-valuemax":xf,"aria-valuenow":A,tabIndex:0,"data-tip":`Drag to resize · double-click (or Home) to reset`,onPointerDown:Dn,onDoubleClick:On,onKeyDown:e=>{e.key===`ArrowLeft`?(e.preventDefault(),En(F.current-16)):e.key===`ArrowRight`?(e.preventDefault(),En(F.current+16)):(e.key===`Home`||e.key===`Enter`)&&(e.preventDefault(),On())}}),(0,S.jsx)(Wu,{files:Ft,delta:Zn,landed:bn,sinceReview:De.changedHunkIds,hasMore:ht<ft.length,onLoadMore:St,layer:Ze?rr:or,overview:!ut&&Qe&&Be,controls:{layer:Ze?ir:sr,navHidden:O,onToggleNav:An,left:_.total-_.viewed,total:_.total,hunksRead:g.viewed,hunksTotal:g.total,hunkAt:b?Qn.findIndex(e=>e.id===b)+1:0,hunkCount:Qn.length,query:V.query,onClearQuery:()=>V.setQuery(``),hiddenQuery:Qe||ut?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:ut?0:Qe?$e?.hidden??0:V.hiddenTests,hiddenReviewed:Qe||ut?0:V.hiddenReviewed,hiddenUnchanged:Qe||ut?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&&Ee(!1)},onFinish:()=>se(!0),stats:e.stats,unsent:fn,viewMode:v,onSetViewMode:y,allCollapsed:E.size>=e.files.length&&e.files.length>0,onToggleCollapseAll:()=>D(t=>t.size>=e.files.length?new Set:new Set(e.files.map(e=>e.path)))},viewed:u,onToggleFileViewed:Pn,selectedId:b,onSelect:C,viewMode:v,collapsed:E,onToggleCollapsed:jn,comments:Hn})]}),oe&&(e.pr?(0,S.jsx)(Ju,{coverage:_n,presence:r,onFinish:Tn,onInvite:()=>{se(!1),B(!0)},onClose:()=>se(!1)}):(0,S.jsx)($a,{coverage:_n,presence:r,checkOff:xn,onResolve:Cn,onReopen:wn,onFinish:Tn,onInvite:()=>{se(!1),B(!0)},onClose:()=>se(!1)})),ce&&(0,S.jsx)(It,{total:I?.threads.length??0,past:G.length,outdated:G.filter(e=>e.github?.outdated===!0).length,onClear:vn,onClose:()=>le(!1)}),(0,S.jsx)(Nt,{notices:Yn.notices,onOpen:Yn.open,onDismiss:Yn.dismiss,onClear:Yn.clear,onOpenMonitor:()=>qt(!0)}),ge.status&&(0,S.jsx)(vd,{status:ge.status,onShown:ge.markShown,onAcknowledge:ge.acknowledge}),_e&&ge.status&&(0,S.jsx)(il,{status:ge.status,onSetEnabled:ge.setEnabled,onClose:()=>ve(!1)}),ue&&(0,S.jsx)(Ku,{onClose:()=>de(!1)}),z&&(0,S.jsx)(Jo,{presence:r,reason:i,onClose:()=>B(!1)}),(0,S.jsx)(id,{files:e?.files??kf,onJump:zn})]})}):null}function Ff(){return(0,S.jsxs)(T,{client:_f,children:[(0,S.jsx)(At,{}),(0,S.jsx)(Pf,{})]})}var If=400,Lf=300;function Rf(){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<Lf;l(),n=e,t||o?c():i=setTimeout(c,If)},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`})}Yd(qd()),(0,at.createRoot)(document.getElementById(`root`)).render((0,S.jsxs)(x.StrictMode,{children:[(0,S.jsx)(Ff,{}),(0,S.jsx)(Rf,{})]}));export{u as a,s as i,gr as n,l as o,o as r,X as t};
|