@intent-hq/web 2.370.1 → 2.370.2
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/package.json +1 -1
- package/web/app/immutable/chunks/{Dk-rIzdO.js → 2fnkFLNz.js} +1 -1
- package/web/app/immutable/chunks/{Z-hUD4Ap.js → 37RwnxdA.js} +1 -1
- package/web/app/immutable/chunks/{pehcYFWW.js → 5LALF9-w.js} +2 -2
- package/web/app/immutable/chunks/{CFq9q-gu.js → 5eDYSo3l.js} +1 -1
- package/web/app/immutable/chunks/{DG-AKB01.js → 61v4Xd-q.js} +1 -1
- package/web/app/immutable/chunks/{D1_IbOsX.js → 6VefuM40.js} +1 -1
- package/web/app/immutable/chunks/{BBvc0xcX.js → 8kPgwy6s.js} +1 -1
- package/web/app/immutable/chunks/{DqaHaAl1.js → B-7g-jyw.js} +3 -3
- package/web/app/immutable/chunks/{Baepgj8b.js → B4F8uEiO.js} +1 -1
- package/web/app/immutable/chunks/{BHe6JG_C.js → B7nQiJX-.js} +2 -2
- package/web/app/immutable/chunks/{DOIzLCtE.js → BFgsQcq9.js} +1 -1
- package/web/app/immutable/chunks/{CKfVT02n.js → BGndkjol.js} +2 -2
- package/web/app/immutable/chunks/{bLKIt_n4.js → BLaGtfsC.js} +1 -1
- package/web/app/immutable/chunks/{Ca6eVlSm.js → BM1qSBOB.js} +1 -1
- package/web/app/immutable/chunks/{XagMlRFc.js → BOWO4Ybr.js} +2 -2
- package/web/app/immutable/chunks/{DYzJKeX7.js → BPOdNeJW.js} +1 -1
- package/web/app/immutable/chunks/{B2_coen2.js → BR1Dvtpp.js} +1 -1
- package/web/app/immutable/chunks/{BIDxyGuw.js → BR9APAxb.js} +1 -1
- package/web/app/immutable/chunks/{BKq-hmnE.js → BS5Nujz5.js} +1 -1
- package/web/app/immutable/chunks/{Dp08eKy3.js → BTodhwDl.js} +1 -1
- package/web/app/immutable/chunks/{Q1s61YDh.js → BWu7Gpqf.js} +13 -13
- package/web/app/immutable/chunks/{JZ27Qh_j.js → BZJ31k0Z.js} +1 -1
- package/web/app/immutable/chunks/{3bNhkT-J.js → BZgI7WU1.js} +1 -1
- package/web/app/immutable/chunks/{yScsjjST.js → BcrA9Yen.js} +1 -1
- package/web/app/immutable/chunks/{CIvyT4T_.js → BdJsd1ki.js} +1 -1
- package/web/app/immutable/chunks/{BJDeJSt-.js → Bfp4ruWu.js} +1 -1
- package/web/app/immutable/chunks/{DkL69EQl.js → BgE7NCeJ.js} +1 -1
- package/web/app/immutable/chunks/{weHhj1in.js → BghZcrpF.js} +1 -1
- package/web/app/immutable/chunks/{VcOG8L0Z.js → BiVa9bC9.js} +1 -1
- package/web/app/immutable/chunks/{UO171Id4.js → BkG4Behb.js} +1 -1
- package/web/app/immutable/chunks/{Ds4DhRwW.js → BpcFcSgh.js} +1 -1
- package/web/app/immutable/chunks/{BeVAskuR.js → Bq3GMUqF.js} +1 -1
- package/web/app/immutable/chunks/{C29Jqwzt.js → BrGoXwG8.js} +1 -1
- package/web/app/immutable/chunks/{1BRHaRmm.js → Bsyy-0lH.js} +3 -3
- package/web/app/immutable/chunks/{DfJwQVW8.js → BxN9s7AP.js} +1 -1
- package/web/app/immutable/chunks/{Dg9ZuAkk.js → Bzz0c_ry.js} +2 -2
- package/web/app/immutable/chunks/{DSjbk-ao.js → C-IS8SBb.js} +1 -1
- package/web/app/immutable/chunks/{KSJAkSbC.js → C30xT9-i.js} +1 -1
- package/web/app/immutable/chunks/{Dr6C4F1X.js → C3pE6msh.js} +1 -1
- package/web/app/immutable/chunks/{BVDDJIsV.js → C5T8uUpU.js} +1 -1
- package/web/app/immutable/chunks/{BSwUOmEO.js → C5pJ7DEG.js} +1 -1
- package/web/app/immutable/chunks/{DM71GnMx.js → CELHofTd.js} +3 -3
- package/web/app/immutable/chunks/{Bo89tkt2.js → CFdTsqjt.js} +1 -1
- package/web/app/immutable/chunks/{CQWMr-uu.js → CHvjIWnN.js} +2 -2
- package/web/app/immutable/chunks/{2IbSEmAW.js → CMYDhfVs.js} +1 -1
- package/web/app/immutable/chunks/{Ce83awb2.js → CQCytUET.js} +2 -2
- package/web/app/immutable/chunks/{SLPWQR3F.js → CQiC3L5q.js} +1 -1
- package/web/app/immutable/chunks/{2kcdsiKR.js → CRhdiLrU.js} +1 -1
- package/web/app/immutable/chunks/{BTBYrxZV.js → CTBZXNUF.js} +1 -1
- package/web/app/immutable/chunks/{wK4T9_HO.js → CUj3qXAR.js} +1 -1
- package/web/app/immutable/chunks/{Dbrv6RE-.js → CWOeseZJ.js} +1 -1
- package/web/app/immutable/chunks/{DmC2lRsL.js → CX-8a7xU.js} +2 -2
- package/web/app/immutable/chunks/{CdYt8dgZ.js → CX-WDgpQ.js} +1 -1
- package/web/app/immutable/chunks/{BIH1E0JD.js → CZ0MIbMm.js} +1 -1
- package/web/app/immutable/chunks/{DSCqJfZ-.js → C_WatYYk.js} +1 -1
- package/web/app/immutable/chunks/{7aKXh--T.js → CcCeOCLG.js} +3 -3
- package/web/app/immutable/chunks/{CFcZXBVA.js → CcYjFBrM.js} +1 -1
- package/web/app/immutable/chunks/{DteD0Nal.js → Ce4DeuTo.js} +3 -3
- package/web/app/immutable/chunks/{DqMtaSxK.js → CmdzVgvT.js} +1 -1
- package/web/app/immutable/chunks/{7i9XTDuo.js → CoZeNthD.js} +1 -1
- package/web/app/immutable/chunks/{DqZnld6x.js → Cov6EESF.js} +3 -3
- package/web/app/immutable/chunks/{L-jTlD15.js → CqCZk0ca.js} +3 -3
- package/web/app/immutable/chunks/{Tygff_sj.js → Cr_u-KK4.js} +1 -1
- package/web/app/immutable/chunks/{Czc9XxQH.js → Cw0RkUSg.js} +1 -1
- package/web/app/immutable/chunks/{DMzReQ-5.js → Cxn7PlP-.js} +1 -1
- package/web/app/immutable/chunks/{gTjyNX6h.js → Cxs4PvAD.js} +1 -1
- package/web/app/immutable/chunks/{BgnxwWhQ.js → Cy9k09g5.js} +1 -1
- package/web/app/immutable/chunks/{DUO0KBjx.js → CzM5SEDv.js} +1 -1
- package/web/app/immutable/chunks/{DnsVLkb8.js → D2dH0brU.js} +1 -1
- package/web/app/immutable/chunks/{C-5vE6yh.js → D3gleuKc.js} +4 -4
- package/web/app/immutable/chunks/{BKzqt9uo.js → D4D4msrU.js} +1 -1
- package/web/app/immutable/chunks/{OltbXq5G.js → D5-1hxdu.js} +1 -1
- package/web/app/immutable/chunks/{BU9a7SkD.js → D5MxzPoI.js} +1 -1
- package/web/app/immutable/chunks/{W2c1MO7q.js → D8-Qc246.js} +1 -1
- package/web/app/immutable/chunks/{Czz4CkiM.js → DDVgDlM2.js} +1 -1
- package/web/app/immutable/chunks/{DRRKH4VP.js → DFMjHFLq.js} +1 -1
- package/web/app/immutable/chunks/{JMqHRN1q.js → DJOX3PaT.js} +1 -1
- package/web/app/immutable/chunks/{Beg3arHH.js → DLfLfqER.js} +1 -1
- package/web/app/immutable/chunks/{CVXKL6ab.js → DNF6envV.js} +1 -1
- package/web/app/immutable/chunks/{ENlRNbf0.js → DNbpqTjh.js} +1 -1
- package/web/app/immutable/chunks/{K2mnFSgK.js → DOiozQGI.js} +1 -1
- package/web/app/immutable/chunks/{BL5h9RCy.js → DP7n2Ccw.js} +1 -1
- package/web/app/immutable/chunks/{DfT1buZq.js → DTbH-mAR.js} +2 -2
- package/web/app/immutable/chunks/{CC-xReBN.js → DUAki0uS.js} +1 -1
- package/web/app/immutable/chunks/{DbIuIgjV.js → DUj14ka7.js} +1 -1
- package/web/app/immutable/chunks/{D4hsFsw4.js → DY9gJ8US.js} +1 -1
- package/web/app/immutable/chunks/{BhA_kLCx.js → D_izGjgJ.js} +1 -1
- package/web/app/immutable/chunks/{xCaPmms8.js → DcnKM2c0.js} +1 -1
- package/web/app/immutable/chunks/{CTKKTfh5.js → DgTfsal1.js} +2 -2
- package/web/app/immutable/chunks/{DbN2kVX-.js → Dk27S3e8.js} +1 -1
- package/web/app/immutable/chunks/{D8Nxo4aC.js → DlGpNWpV.js} +1 -1
- package/web/app/immutable/chunks/{CzMPk75T.js → DnV9eAGG.js} +1 -1
- package/web/app/immutable/chunks/{B3hSlB6y.js → DnfgukfK.js} +1 -1
- package/web/app/immutable/chunks/{BtrJwCgg.js → Dqa8MqiX.js} +1 -1
- package/web/app/immutable/chunks/{CO9mOa2z.js → DqvpZseI.js} +1 -1
- package/web/app/immutable/chunks/{PtFvwTVZ.js → Dr1T9Ela.js} +3 -3
- package/web/app/immutable/chunks/{nrAGmqbi.js → DrBfRK-l.js} +1 -1
- package/web/app/immutable/chunks/{Bb3w2fM6.js → DuR22uzB.js} +1 -1
- package/web/app/immutable/chunks/{CNkmihEX.js → DxOqqCxd.js} +2 -2
- package/web/app/immutable/chunks/{BR_GHabc.js → F6KnEzK2.js} +1 -1
- package/web/app/immutable/chunks/{CxJ0MhK_.js → IbOrXYhr.js} +3 -3
- package/web/app/immutable/chunks/{DUfE7lx2.js → MmbRHAVV.js} +1 -1
- package/web/app/immutable/chunks/{Ba5gf06c.js → RMFOakJ8.js} +1 -1
- package/web/app/immutable/chunks/{CkoG9STP.js → Rtb2u0aS.js} +1 -1
- package/web/app/immutable/chunks/{DRWqzfiQ.js → S0vfIVN4.js} +1 -1
- package/web/app/immutable/chunks/{CENbvXsw.js → Tl9_Ag57.js} +1 -1
- package/web/app/immutable/chunks/{Cum1dYpM.js → YcLv7RIG.js} +1 -1
- package/web/app/immutable/chunks/{BqOLTDDX.js → YjkXFMdR.js} +1 -1
- package/web/app/immutable/chunks/{2CvTs4Gl.js → YlOhdwpJ.js} +1 -1
- package/web/app/immutable/chunks/{eNRNxfO0.js → ZiiliHwl.js} +1 -1
- package/web/app/immutable/chunks/{C_V6o9Il.js → a-02PhaD.js} +1 -1
- package/web/app/immutable/chunks/{Cmj0JylI.js → deZv7xr3.js} +1 -1
- package/web/app/immutable/chunks/{BalxhI2Q.js → e6y6K_3x.js} +1 -1
- package/web/app/immutable/chunks/{Dax7ITFa.js → eHZL9ha9.js} +1 -1
- package/web/app/immutable/chunks/{CC4-q0Fm.js → l3HuVu6N.js} +1 -1
- package/web/app/immutable/chunks/{DIhsiUIT.js → lUjoTdjg.js} +1 -1
- package/web/app/immutable/chunks/{aitTA173.js → mPd0q3-n.js} +4 -4
- package/web/app/immutable/chunks/{B5LyNSS1.js → mdamofpo.js} +1 -1
- package/web/app/immutable/chunks/{CllirvEK.js → mwFmA_HW.js} +1 -1
- package/web/app/immutable/chunks/{DUl-h1p3.js → qOqJpb_a.js} +1 -1
- package/web/app/immutable/chunks/{DhWcN4bx.js → wNJjv8Uj.js} +1 -1
- package/web/app/immutable/chunks/{CT012uiB.js → xIIgydKf.js} +1 -1
- package/web/app/immutable/chunks/{BE3ifD-D.js → z2CLzpx7.js} +1 -1
- package/web/app/immutable/entry/{app.De5C2NS7.js → app.CC3URvKW.js} +2 -2
- package/web/app/immutable/entry/start.C3bg9se6.js +1 -0
- package/web/app/immutable/nodes/{0.D8lcICdy.js → 0.C4aXi2Zc.js} +1 -1
- package/web/app/immutable/nodes/{1.Bcr9Ac6T.js → 1.O03B6KYk.js} +1 -1
- package/web/app/immutable/nodes/{10.CdYxZNRv.js → 10.DSjz-a23.js} +4 -4
- package/web/app/immutable/nodes/{11.DTALKQkg.js → 11.DUbB-MHX.js} +1 -1
- package/web/app/immutable/nodes/{15.BuZ5Ykpn.js → 15.BU8WwWus.js} +1 -1
- package/web/app/immutable/nodes/{19.Bwna1DuW.js → 19.C3kZuMc1.js} +2 -2
- package/web/app/immutable/nodes/2.SHzQR8g8.js +13 -0
- package/web/app/immutable/nodes/{3.CJlWKIE-.js → 3.D7EtacCx.js} +1 -1
- package/web/app/immutable/nodes/{4.CDSfo4Q5.js → 4._-Ygm1PE.js} +1 -1
- package/web/app/immutable/nodes/{5.B6hsM1cw.js → 5.B5veLa-N.js} +1 -1
- package/web/app/immutable/nodes/{6.DCm27sfe.js → 6.BnrdHFCS.js} +1 -1
- package/web/app/immutable/nodes/{7.Dd2x1_y1.js → 7.DAUgpsnC.js} +1 -1
- package/web/app/immutable/nodes/{8.C0jzmTGW.js → 8.Cj1FZ4Vr.js} +1 -1
- package/web/app/immutable/nodes/{9.Bj88iDsv.js → 9.BuIEgUbP.js} +4 -4
- package/web/app/version.json +1 -1
- package/web/index.html +9 -9
- package/web/app/immutable/entry/start.BbOZiO5_.js +0 -1
- package/web/app/immutable/nodes/2.BCkphmFm.js +0 -13
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var $s=Object.defineProperty;var Fs=(f,r,l)=>r in f?$s(f,r,{enumerable:!0,configurable:!0,writable:!0,value:l}):f[r]=l;var q=(f,r,l)=>Fs(f,typeof r!="symbol"?r+"":r,l);import{t as dn,bo as C,bm as P,bw as un,bq as On,b as hn,bs as je}from"./51_h0jm2.js";import{ai as xr,bs as gn,ca as Be,aD as e,bH as m,a5 as N,bA as H,b_ as z,aw as sn,aj as ln,W as w,bn as fn,bV as J,aA as x,ay as ne,bS as y,bl as de,bO as K,aB as T,c9 as u,a7 as nt,br as tt,bj as sr,c5 as gt,c0 as Ln,a as Us,be as Tt,b$ as ft,bf as or}from"./CJxGDkBm.js";import{i as M}from"./PXCFrn2V.js";import{g as Pt,i as Hn,I as ir,e as ar}from"./Bjy4ygfJ.js";import{n as cn,l as Ws,c as Bs}from"./BxwkoIbZ.js";import{f as En,s as Ve,g as lr}from"./CpPNoOk-.js";import{b as on}from"./NtFyWdpR.js";import{J5 as Me,eK as Vs,eB as Ks,eC as js,oP as qs,nD as Vt,nH as cr,nG as In,eE as Gs,vq as Qs,vr as Xs,vt as Js,H9 as Ys,Ja as Zs,rI as eo,eJ as to}from"./CI4_aI7e.js";import{c as no}from"./CQIdhUGs.js";import{F as Ne,a1 as ro,a8 as An,aw as dr,ax as ur,bS as so,aP as oo,cd as hr,bZ as gr,cq as fr}from"./DSQT151l.js";import{dE as io,bp as ao,X as lo,aN as mr,p as co}from"./C2wWLl1x.js";import{L as pr}from"./DYmzWBEk.js";import{C as an}from"./DypB-Dwi.js";import{b8 as kr,bN as uo,bT as ho}from"./DqMtaSxK.js";import{q as $e,d as go,g as fo}from"./CkoG9STP.js";import"./DxvSggY5.js";import"./rIUowGAi.js";/* empty css */import{T as Pr}from"./CFcZXBVA.js";import{g as Nn}from"./DcsxLfDg.js";import{A as mo}from"./FmBB5PWm.js";import{f as ke}from"./BnA9v3pc.js";import{C as po}from"./C6ROKFdp.js";import{C as vo}from"./Cz-HgbT1.js";import{s as vr}from"./CzMPk75T.js";import{S as Dt}from"./rei1qYSi.js";import{l as Rt}from"./DqFWZ_g1.js";import{G as _r}from"./Cl7NoY6M.js";import{P as _o}from"./JvjGgKob.js";import{g as wo}from"./DkkmguuG.js";import{a8 as bo,Y as So}from"./DhWcN4bx.js";import{ap as yo}from"./DqaHaAl1.js";import{L as wr}from"./1BRHaRmm.js";import{ae as Co,ad as xo,af as ko}from"./Q1s61YDh.js";function br({scrollTop:f,scrollHeight:r,height:l,fitPerfectly:a=!1,fitPerfectlyOverscroll:c=0,overscrollSize:p}){const b=l+p*2,S=a?l+c*2:b;if(r=Math.max(r,S),b>=r||a){const G=Math.max(f-c,0),h=Math.min(f+S,r);return{top:G,bottom:Math.max(h,G)}}let A=f+l/2-b/2,F=A+b;return A<0&&(A=0),F>r&&(F=r),A=Math.floor(Math.max(A,0)),{top:A,bottom:Math.ceil(Math.max(Math.min(F,r),A))}}function Po(f,r){return f==null||r==null?f===r:f.top===r.top&&f.bottom===r.bottom}const Rr=1e3,Ro=Rr*4,Lo=[0,1e-6,.99999,1],Ho={overscrollSize:Rr,intersectionObserverMargin:Ro,resizeDebugging:!1};let rn=0,Io=-1;var Pe,Ao=(Pe=class{constructor(r){q(this,"__id",`virtualizer-${++Io}`);q(this,"config");q(this,"type","simple");q(this,"intersectionObserver");q(this,"scrollTop",0);q(this,"height",0);q(this,"scrollHeight",0);q(this,"windowSpecs",{top:0,bottom:0});q(this,"root");q(this,"contentContainer");q(this,"resizeObserver");q(this,"observers",new Map);q(this,"visibleInstances",new Map);q(this,"visibleInstancesDirty",!1);q(this,"instancesChanged",new Set);q(this,"reconcileQueue",new Set);q(this,"scrollDirty",!0);q(this,"heightDirty",!0);q(this,"scrollHeightDirty",!0);q(this,"renderedObservers",0);q(this,"connectQueue",new Map);q(this,"handleContainerResize",r=>{if(this.root==null)return;let l=!1;for(const a of r){const c=a.borderBoxSize[0].blockSize;this.root instanceof Document?c!==this.scrollHeight&&(this.scrollHeightDirty=!0,l=!0,this.config.resizeDebugging&&(console.log("Virtualizer: content size change",this.__id,{sizeChange:c-rn,newSize:c}),rn=c)):a.target===this.root?c!==this.height&&(this.heightDirty=!0,l=!0):a.target===this.contentContainer&&(this.scrollHeightDirty=!0,l=!0,this.config.resizeDebugging&&(console.log("Virtualizer: scroller size change",this.__id,{sizeChange:c-rn,newSize:c}),rn=c))}l&&$e(this.computeRenderRangeAndEmit)});q(this,"handleWindowResize",()=>{Pe.__STOP||window.innerHeight===this.height||(this.heightDirty=!0,$e(this.computeRenderRangeAndEmit))});q(this,"handleWindowScroll",()=>{Pe.__STOP||this.root==null||!(this.root instanceof Document)||(this.scrollDirty=!0,$e(this.computeRenderRangeAndEmit))});q(this,"handleElementScroll",()=>{Pe.__STOP||this.root==null||this.root instanceof Document||(this.scrollDirty=!0,$e(this.computeRenderRangeAndEmit))});q(this,"computeRenderRangeAndEmit",()=>{if(Pe.__STOP)return;const r=this.heightDirty||this.scrollHeightDirty;let l=this.instancesChanged.size>0;if(this.instancesChanged.size===0){const p=br({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize});if(!r&&Po(this.windowSpecs,p)&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty&&this.reconcileQueue.size===0)return;this.windowSpecs=p}this.visibleInstancesDirty=!1,this.renderedObservers=this.observers.size;const a=this.getScrollAnchor(this.height),c=new Set;for(const p of r?this.observers.values():this.visibleInstances.values())p.onRender(r)&&c.add(p);for(const p of this.instancesChanged)c.has(p)||p.onRender(r)&&c.add(p);this.scrollFix(a);for(const p of c)this.reconcileQueue.delete(p),p.reconcileHeights();for(const p of this.reconcileQueue)p.reconcileHeights()&&(l=!0);this.reconcileQueue.clear(),l||=this.instancesChanged.size>0,l&&this.markDOMDirty(),(l||r)&&$e(this.computeRenderRangeAndEmit),c.clear(),this.instancesChanged.clear()});q(this,"handleIntersectionChange",r=>{this.scrollDirty=!0;for(const{target:l,isIntersecting:a}of r){if(!(l instanceof HTMLElement))throw new Error("Virtualizer.handleIntersectionChange: target not an HTMLElement");const c=this.observers.get(l);c!=null&&(a&&!this.visibleInstances.has(l)?(c.setVisibility(!0),this.visibleInstances.set(l,c),this.visibleInstancesDirty=!0):!a&&this.visibleInstances.has(l)&&(c.setVisibility(!1),this.visibleInstances.delete(l),this.visibleInstancesDirty=!0))}this.visibleInstancesDirty&&$e(this.computeRenderRangeAndEmit)});this.config={...Ho,...r}}setup(r,l){if(this.root==null){this.root=r,this.resizeObserver=new ResizeObserver(this.handleContainerResize),this.intersectionObserver=new IntersectionObserver(this.handleIntersectionChange,{root:this.root,threshold:Lo,rootMargin:`${this.config.intersectionObserverMargin}px 0px ${this.config.intersectionObserverMargin}px 0px`}),r instanceof Document?this.setupWindow():this.setupElement(l),window.__INSTANCE=this,window.__TOGGLE=()=>{Pe.__STOP?(Pe.__STOP=!1,(this.getScrollContainerElement()??window).scrollTo({top:Pe.__lastScrollPosition}),$e(this.computeRenderRangeAndEmit)):(Pe.__lastScrollPosition=this.getScrollTop(),Pe.__STOP=!0)};for(const[a,c]of this.connectQueue.entries())this.connect(a,c);this.connectQueue.clear(),this.markDOMDirty(),$e(this.computeRenderRangeAndEmit)}}instanceChanged(r,l){this.instancesChanged.add(r),l&&this.markDOMDirty(),$e(this.computeRenderRangeAndEmit)}requestHeightReconcile(r){this.reconcileQueue.add(r),$e(this.computeRenderRangeAndEmit)}getWindowSpecs(){return this.windowSpecs.top===0&&this.windowSpecs.bottom===0&&(this.windowSpecs=br({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize})),this.windowSpecs}getRoot(){return this.root}isInstanceVisible(r,l){const a=this.getScrollTop(),c=this.getHeight(),p=this.config.intersectionObserverMargin,b=a-p,S=a+c+p;return!(r<b-l||r>S)}setupWindow(){if(this.root==null||!(this.root instanceof Document))throw new Error("Virtualizer.setupWindow: Invalid setup method");window.addEventListener("scroll",this.handleWindowScroll,{passive:!0}),window.addEventListener("resize",this.handleWindowResize,{passive:!0}),this.resizeObserver?.observe(this.root.documentElement)}setupElement(r){if(this.root==null||this.root instanceof Document)throw new Error("Virtualizer.setupElement: Invalid setup method");this.root.addEventListener("scroll",this.handleElementScroll,{passive:!0}),this.resizeObserver?.observe(this.root),r??=this.root.firstElementChild??void 0,r instanceof HTMLElement&&(this.contentContainer=r,this.resizeObserver?.observe(r))}cleanUp(){go(this.computeRenderRangeAndEmit),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.root?.removeEventListener("scroll",this.handleElementScroll),window.removeEventListener("scroll",this.handleWindowScroll),window.removeEventListener("resize",this.handleWindowResize),this.root=void 0,this.contentContainer=void 0,this.observers.clear(),this.visibleInstances.clear(),this.instancesChanged.clear(),this.reconcileQueue.clear(),this.connectQueue.clear(),this.visibleInstancesDirty=!1,this.windowSpecs={top:0,bottom:0},this.scrollTop=0,this.height=0,this.scrollHeight=0,this.scrollDirty=!0,this.heightDirty=!0,this.scrollHeightDirty=!0}getOffsetInScrollContainer(r){return this.getScrollTop()+Kt(r,this.getScrollContainerElement())}connect(r,l){if(this.observers.has(r))throw new Error("Virtualizer.connect: instance is already connected...");return this.intersectionObserver==null?this.connectQueue.set(r,l):(this.intersectionObserver.observe(r),this.observers.set(r,l),this.instancesChanged.add(l),this.markDOMDirty(),$e(this.computeRenderRangeAndEmit)),()=>this.disconnect(r)}disconnect(r){const l=this.observers.get(r);this.connectQueue.delete(r),l!=null&&(this.intersectionObserver?.unobserve(r),this.observers.delete(r),this.instancesChanged.delete(l),this.reconcileQueue.delete(l),this.visibleInstances.delete(r)&&(this.visibleInstancesDirty=!0),this.markDOMDirty(),$e(this.computeRenderRangeAndEmit))}scrollFix(r){if(r==null)return;const l=this.getScrollContainerElement(),{lineIndex:a,lineOffset:c,fileElement:p,fileOffset:b,fileTypeOffset:S}=r;if(a!=null&&c!=null){const F=p.shadowRoot?.querySelector(`[data-line][data-line-index="${a}"]`);if(F instanceof HTMLElement){const G=Kt(F,l);if(G!==c){const h=G-c;this.applyScrollFix(h)}return}}const A=Kt(p,l);if(S==="top")A!==b&&this.applyScrollFix(A-b);else{const F=A+p.getBoundingClientRect().height;F!==b&&this.applyScrollFix(F-b)}}applyScrollFix(r){this.root==null||this.root instanceof Document?window.scrollTo({top:window.scrollY+r,behavior:"instant"}):this.root.scrollTo({top:this.root.scrollTop+r,behavior:"instant"}),this.markDOMDirty()}getScrollAnchor(r){const l=this.getScrollContainerElement();let a;for(const[c]of this.visibleInstances.entries()){const p=Kt(c,l),b=p+c.offsetHeight;let S,A;b<=0?(S=b,A="bottom"):(S=p,A="top");let F,G;if(b>0&&p<r)for(const oe of c.shadowRoot?.querySelectorAll("[data-line][data-line-index]")??[]){if(!(oe instanceof HTMLElement))continue;const Te=oe.dataset.lineIndex;if(Te==null)continue;const ue=Kt(oe,l);if(!(ue<0)){F=Te,G=ue;break}}if(a?.lineOffset!=null&&G==null)continue;let h=!1;(a==null||G!=null&&(a.lineOffset==null||G<a.lineOffset)||G==null&&a.lineOffset==null&&(S>=0&&(a.fileOffset<0||S<a.fileOffset)||S<0&&a.fileOffset<0&&S>a.fileOffset))&&(h=!0),h&&(a={fileElement:c,fileTypeOffset:A,fileOffset:S,lineIndex:F,lineOffset:G})}return a}getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let r=this.root==null?0:this.root instanceof Document?window.scrollY:this.root.scrollTop;return r=this.clampScrollTop(r),this.scrollTop=r,r}scrollTo({top:r,behavior:l="auto"}){const{root:a}=this;if(a==null)return;const c=this.clampScrollTop(r);a instanceof Document?window.scrollTo({top:c,behavior:l}):a.scrollTo({top:c,behavior:l}),this.scrollDirty=!0,$e(this.computeRenderRangeAndEmit)}clampScrollTop(r){return Math.max(0,Math.min(r,this.getScrollHeight()-this.getHeight()))}getScrollHeight(){return this.scrollHeightDirty?(this.scrollHeightDirty=!1,this.scrollHeight=this.root==null?0:this.root instanceof Document?this.root.documentElement.scrollHeight:this.root.scrollHeight,this.scrollHeight):this.scrollHeight}getHeight(){return this.heightDirty?(this.heightDirty=!1,this.height=this.root==null?0:this.root instanceof Document?globalThis.innerHeight:this.root.getBoundingClientRect().height,this.height):this.height}markDOMDirty(){this.scrollDirty=!0,this.scrollHeightDirty=!0,this.heightDirty=!0}getScrollContainerElement(){return this.root==null||this.root instanceof Document?void 0:this.root}},q(Pe,"__STOP",!1),q(Pe,"__lastScrollPosition",0),Pe);function Kt(f,r){const l=f.getBoundingClientRect(),a=r?.getBoundingClientRect().top??0;return l.top-a}var Eo=T('<div class="absolute inset-0 flex items-center justify-center rounded-lg bg-background/60 backdrop-blur-[2px] transition-opacity duration-spring-moderate ease-spring-moderate motion-reduce:transition-none z-10 pointer-events-none"><div class="flex items-center gap-2 rounded-lg border border-border bg-card px-3 py-2 text-xs font-medium text-subtle shadow-lg"><!> </div></div>'),Oo=T("<!> <!>",1),No=T('<div class="flex h-24 items-center justify-start text-left text-subtle"> </div>'),To=T('<div role="region"><!></div>');function Lr(f,r){if(new.target)return dn({component:Lr,...f});gn(r,!0);const l=()=>je(ve,"$sideBySide",a),[a,c]=On(),p=Nn()?.workspaceId??void 0;let b=C(r,"change",7),S=C(r,"foldUnchanged",7,!0),A=C(r,"allowHeadReads",7,!0),F=C(r,"canReadHeadFiles",7),G=C(r,"lineWrapping",7,!1),h=C(r,"scrollToLine",7),oe=C(r,"isAggregate",7,!1),Te=C(r,"showScrollHint",7,!1),ue=C(r,"onStageHunk",7),Q=C(r,"onUnstageHunk",7),at=C(r,"onOpenCommit",7),pt=C(r,"virtualizer",7),vt=C(r,"gitRootId",7,void 0),_t=C(r,"gitRootPath",7,void 0);const ve=kr();let Re=J(!1),Se=J(!1),Fe=J(!1),Ue=J(0),qe=J(void 0);const $=80;function ie(){m(Se,!0)}function De(){m(Se,!1),m(Fe,!1),m(Ue,0)}function Le(v){!e(Se)||e(Re)||(m(Ue,e(Ue)+Math.abs(v.deltaY)),e(Ue)>=$&&!e(Fe)&&m(Fe,!0))}function jt(){m(Re,!0),m(Fe,!1),m(Ue,0)}function qt(v){e(qe)&&!e(qe).contains(v.relatedTarget)&&m(Re,!1)}Be(()=>{(e(Re)||!e(Se))&&(m(Fe,!1),m(Ue,0))});let Lt=u(()=>{const{toolCallId:v,filePath:_e,additions:Qe,deletions:St,oldContent:re,newContent:Xe}=b(),rt="staged"in b()&&b().staged===!0,Ke="category"in b()?b().category:void 0,At="commitHash"in b()?b().commitHash:void 0,zt="gitlink"in b()?b().gitlink:void 0,Mt="isFullFileContent"in b()?b().isFullFileContent:!1;let yt;return Ke==="committed"?yt=an.Committed:rt?yt=an.Staged:yt=an.Unstaged,{id:v,file:_e,relativePath:_e,stage:yt,commitHash:At,gitlink:zt,stats:{additions:Qe,deletions:St},attribution:{timestamp:0},content:re!==void 0||Xe!==void 0?{oldContent:re??"",newContent:Xe??"",isFullFileContent:Mt}:void 0}});const D=u(()=>b().isFullFileContent?1:("chunks"in b()?b().chunks?.[0]?.newStart:void 0)??b().startLineNumber??1);var Ht={get change(){return b()},set change(v){b(v),x()},get foldUnchanged(){return S()},set foldUnchanged(v=!0){S(v),x()},get allowHeadReads(){return A()},set allowHeadReads(v=!0){A(v),x()},get canReadHeadFiles(){return F()},set canReadHeadFiles(v){F(v),x()},get lineWrapping(){return G()},set lineWrapping(v=!1){G(v),x()},get scrollToLine(){return h()},set scrollToLine(v){h(v),x()},get isAggregate(){return oe()},set isAggregate(v=!1){oe(v),x()},get showScrollHint(){return Te()},set showScrollHint(v=!1){Te(v),x()},get onStageHunk(){return ue()},set onStageHunk(v){ue(v),x()},get onUnstageHunk(){return Q()},set onUnstageHunk(v){Q(v),x()},get onOpenCommit(){return at()},set onOpenCommit(v){at(v),x()},get virtualizer(){return pt()},set virtualizer(v){pt(v),x()},get gitRootId(){return vt()},set gitRootId(v=void 0){vt(v),x()},get gitRootPath(){return _t()},set gitRootPath(v=void 0){_t(v),x()},$set:un,$on:(v,_e)=>hn(r,v,_e)},He=To();let wt;var It=N(He);{var Ge=v=>{var _e=Oo(),Qe=ne(_e);{let Xe=u(()=>l()?"split":"unified");Pr(Qe,{get change(){return e(Lt)},get workspaceId(){return p},get viewMode(){return e(Xe)},get foldUnchanged(){return S()},get lineWrapping(){return G()},get onStageHunk(){return ue()},get onUnstageHunk(){return Q()},useProvidedContent:!0,get allowHeadReads(){return A()},get canReadHeadFiles(){return F()},get lineOffset(){return e(D)},get virtualizer(){return pt()},get gitRootId(){return vt()},get gitRootPath(){return _t()}})}var St=y(Qe,2);{var re=Xe=>{var rt=Eo(),Ke=N(rt),At=N(Ke);Ne(At,{get icon(){return ro},class:"w-3 h-3"});var zt=y(At);H(Ke),H(rt),z(Mt=>K(zt,` ${Mt??""}`),[()=>P.chat_inlineDiffItem_clickToScroll_label()]),cn(1,rt,()=>Ws,()=>({tier:"fast",y:0,scale:1})),cn(2,rt,()=>Bs,()=>({tier:"fast"})),w(Xe,rt)};M(St,Xe=>{Te()&&e(Fe)&&Xe(re)})}w(v,_e)},bt=v=>{var _e=No(),Qe=de(_e,!0);z(St=>K(Qe,St),[()=>P.chat_inlineDiffItem_noWorkspace_label()]),w(v,_e)};M(It,v=>{p?v(Ge):v(bt,-1)})}H(He),on(He,v=>m(qe,v),()=>e(qe)),z(v=>{wt=En(He,1,"inline-diff-container relative",null,wt,{focused:e(Re)}),Ve(He,"aria-label",v)},[()=>P.chat_inlineDiffItem_viewer_ariaLabel()]),sn("mouseenter",He,ie),sn("mouseleave",He,De),sn("wheel",He,Le),ln("focusin",He,jt),ln("focusout",He,qt),w(f,He);var mn=fn(Ht);return c(),mn}xr(["focusin","focusout"]);function Sr(f){return[f.stage,f.type,f.oldLineNumber??"",f.newLineNumber??"",f.content].join("\0")}function Do(f){let r=f.oldStart,l=f.newStart;return f.lines.map(a=>{const c={...a,oldLineNumber:a.oldLineNumber??a.oldNumber,newLineNumber:a.newLineNumber??a.newNumber};return c.oldLineNumber===void 0&&c.newLineNumber===void 0?a.type==="Context"?(c.oldLineNumber=r++,c.newLineNumber=l++):a.type==="Deletion"?c.oldLineNumber=r++:a.type==="Addition"&&(c.newLineNumber=l++):a.type==="Context"?(r=(c.oldLineNumber??r)+1,l=(c.newLineNumber??l)+1):a.type==="Deletion"?r=(c.oldLineNumber??r)+1:a.type==="Addition"&&(l=(c.newLineNumber??l)+1),c})}function zo(f,r){const l=f?f.split(`
|
|
1
|
+
var $s=Object.defineProperty;var Fs=(f,r,l)=>r in f?$s(f,r,{enumerable:!0,configurable:!0,writable:!0,value:l}):f[r]=l;var q=(f,r,l)=>Fs(f,typeof r!="symbol"?r+"":r,l);import{t as dn,bo as C,bm as P,bw as un,bq as On,b as hn,bs as je}from"./51_h0jm2.js";import{ai as xr,bs as gn,ca as Be,aD as e,bH as m,a5 as N,bA as H,b_ as z,aw as sn,aj as ln,W as w,bn as fn,bV as J,aA as x,ay as ne,bS as y,bl as de,bO as K,aB as T,c9 as u,a7 as nt,br as tt,bj as sr,c5 as gt,c0 as Ln,a as Us,be as Tt,b$ as ft,bf as or}from"./CJxGDkBm.js";import{i as M}from"./PXCFrn2V.js";import{g as Pt,i as Hn,I as ir,e as ar}from"./Bjy4ygfJ.js";import{n as cn,l as Ws,c as Bs}from"./BxwkoIbZ.js";import{f as En,s as Ve,g as lr}from"./CpPNoOk-.js";import{b as on}from"./NtFyWdpR.js";import{J5 as Me,eK as Vs,eB as Ks,eC as js,oP as qs,nD as Vt,nH as cr,nG as In,eE as Gs,vq as Qs,vr as Xs,vt as Js,H9 as Ys,Ja as Zs,rI as eo,eJ as to}from"./CI4_aI7e.js";import{c as no}from"./CQIdhUGs.js";import{F as Ne,a1 as ro,a8 as An,aw as dr,ax as ur,bS as so,aP as oo,cd as hr,bZ as gr,cq as fr}from"./DSQT151l.js";import{dE as io,bp as ao,X as lo,aN as mr,p as co}from"./C2wWLl1x.js";import{L as pr}from"./DYmzWBEk.js";import{C as an}from"./DypB-Dwi.js";import{b8 as kr,bN as uo,bT as ho}from"./CmdzVgvT.js";import{q as $e,d as go,g as fo}from"./Rtb2u0aS.js";import"./DxvSggY5.js";import"./rIUowGAi.js";/* empty css */import{T as Pr}from"./CcYjFBrM.js";import{g as Nn}from"./DcsxLfDg.js";import{A as mo}from"./FmBB5PWm.js";import{f as ke}from"./BnA9v3pc.js";import{C as po}from"./C6ROKFdp.js";import{C as vo}from"./Cz-HgbT1.js";import{s as vr}from"./DnV9eAGG.js";import{S as Dt}from"./rei1qYSi.js";import{l as Rt}from"./DqFWZ_g1.js";import{G as _r}from"./Cl7NoY6M.js";import{P as _o}from"./JvjGgKob.js";import{g as wo}from"./DkkmguuG.js";import{a8 as bo,Y as So}from"./wNJjv8Uj.js";import{ap as yo}from"./B-7g-jyw.js";import{L as wr}from"./Bsyy-0lH.js";import{ae as Co,ad as xo,af as ko}from"./BWu7Gpqf.js";function br({scrollTop:f,scrollHeight:r,height:l,fitPerfectly:a=!1,fitPerfectlyOverscroll:c=0,overscrollSize:p}){const b=l+p*2,S=a?l+c*2:b;if(r=Math.max(r,S),b>=r||a){const G=Math.max(f-c,0),h=Math.min(f+S,r);return{top:G,bottom:Math.max(h,G)}}let A=f+l/2-b/2,F=A+b;return A<0&&(A=0),F>r&&(F=r),A=Math.floor(Math.max(A,0)),{top:A,bottom:Math.ceil(Math.max(Math.min(F,r),A))}}function Po(f,r){return f==null||r==null?f===r:f.top===r.top&&f.bottom===r.bottom}const Rr=1e3,Ro=Rr*4,Lo=[0,1e-6,.99999,1],Ho={overscrollSize:Rr,intersectionObserverMargin:Ro,resizeDebugging:!1};let rn=0,Io=-1;var Pe,Ao=(Pe=class{constructor(r){q(this,"__id",`virtualizer-${++Io}`);q(this,"config");q(this,"type","simple");q(this,"intersectionObserver");q(this,"scrollTop",0);q(this,"height",0);q(this,"scrollHeight",0);q(this,"windowSpecs",{top:0,bottom:0});q(this,"root");q(this,"contentContainer");q(this,"resizeObserver");q(this,"observers",new Map);q(this,"visibleInstances",new Map);q(this,"visibleInstancesDirty",!1);q(this,"instancesChanged",new Set);q(this,"reconcileQueue",new Set);q(this,"scrollDirty",!0);q(this,"heightDirty",!0);q(this,"scrollHeightDirty",!0);q(this,"renderedObservers",0);q(this,"connectQueue",new Map);q(this,"handleContainerResize",r=>{if(this.root==null)return;let l=!1;for(const a of r){const c=a.borderBoxSize[0].blockSize;this.root instanceof Document?c!==this.scrollHeight&&(this.scrollHeightDirty=!0,l=!0,this.config.resizeDebugging&&(console.log("Virtualizer: content size change",this.__id,{sizeChange:c-rn,newSize:c}),rn=c)):a.target===this.root?c!==this.height&&(this.heightDirty=!0,l=!0):a.target===this.contentContainer&&(this.scrollHeightDirty=!0,l=!0,this.config.resizeDebugging&&(console.log("Virtualizer: scroller size change",this.__id,{sizeChange:c-rn,newSize:c}),rn=c))}l&&$e(this.computeRenderRangeAndEmit)});q(this,"handleWindowResize",()=>{Pe.__STOP||window.innerHeight===this.height||(this.heightDirty=!0,$e(this.computeRenderRangeAndEmit))});q(this,"handleWindowScroll",()=>{Pe.__STOP||this.root==null||!(this.root instanceof Document)||(this.scrollDirty=!0,$e(this.computeRenderRangeAndEmit))});q(this,"handleElementScroll",()=>{Pe.__STOP||this.root==null||this.root instanceof Document||(this.scrollDirty=!0,$e(this.computeRenderRangeAndEmit))});q(this,"computeRenderRangeAndEmit",()=>{if(Pe.__STOP)return;const r=this.heightDirty||this.scrollHeightDirty;let l=this.instancesChanged.size>0;if(this.instancesChanged.size===0){const p=br({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize});if(!r&&Po(this.windowSpecs,p)&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty&&this.reconcileQueue.size===0)return;this.windowSpecs=p}this.visibleInstancesDirty=!1,this.renderedObservers=this.observers.size;const a=this.getScrollAnchor(this.height),c=new Set;for(const p of r?this.observers.values():this.visibleInstances.values())p.onRender(r)&&c.add(p);for(const p of this.instancesChanged)c.has(p)||p.onRender(r)&&c.add(p);this.scrollFix(a);for(const p of c)this.reconcileQueue.delete(p),p.reconcileHeights();for(const p of this.reconcileQueue)p.reconcileHeights()&&(l=!0);this.reconcileQueue.clear(),l||=this.instancesChanged.size>0,l&&this.markDOMDirty(),(l||r)&&$e(this.computeRenderRangeAndEmit),c.clear(),this.instancesChanged.clear()});q(this,"handleIntersectionChange",r=>{this.scrollDirty=!0;for(const{target:l,isIntersecting:a}of r){if(!(l instanceof HTMLElement))throw new Error("Virtualizer.handleIntersectionChange: target not an HTMLElement");const c=this.observers.get(l);c!=null&&(a&&!this.visibleInstances.has(l)?(c.setVisibility(!0),this.visibleInstances.set(l,c),this.visibleInstancesDirty=!0):!a&&this.visibleInstances.has(l)&&(c.setVisibility(!1),this.visibleInstances.delete(l),this.visibleInstancesDirty=!0))}this.visibleInstancesDirty&&$e(this.computeRenderRangeAndEmit)});this.config={...Ho,...r}}setup(r,l){if(this.root==null){this.root=r,this.resizeObserver=new ResizeObserver(this.handleContainerResize),this.intersectionObserver=new IntersectionObserver(this.handleIntersectionChange,{root:this.root,threshold:Lo,rootMargin:`${this.config.intersectionObserverMargin}px 0px ${this.config.intersectionObserverMargin}px 0px`}),r instanceof Document?this.setupWindow():this.setupElement(l),window.__INSTANCE=this,window.__TOGGLE=()=>{Pe.__STOP?(Pe.__STOP=!1,(this.getScrollContainerElement()??window).scrollTo({top:Pe.__lastScrollPosition}),$e(this.computeRenderRangeAndEmit)):(Pe.__lastScrollPosition=this.getScrollTop(),Pe.__STOP=!0)};for(const[a,c]of this.connectQueue.entries())this.connect(a,c);this.connectQueue.clear(),this.markDOMDirty(),$e(this.computeRenderRangeAndEmit)}}instanceChanged(r,l){this.instancesChanged.add(r),l&&this.markDOMDirty(),$e(this.computeRenderRangeAndEmit)}requestHeightReconcile(r){this.reconcileQueue.add(r),$e(this.computeRenderRangeAndEmit)}getWindowSpecs(){return this.windowSpecs.top===0&&this.windowSpecs.bottom===0&&(this.windowSpecs=br({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize})),this.windowSpecs}getRoot(){return this.root}isInstanceVisible(r,l){const a=this.getScrollTop(),c=this.getHeight(),p=this.config.intersectionObserverMargin,b=a-p,S=a+c+p;return!(r<b-l||r>S)}setupWindow(){if(this.root==null||!(this.root instanceof Document))throw new Error("Virtualizer.setupWindow: Invalid setup method");window.addEventListener("scroll",this.handleWindowScroll,{passive:!0}),window.addEventListener("resize",this.handleWindowResize,{passive:!0}),this.resizeObserver?.observe(this.root.documentElement)}setupElement(r){if(this.root==null||this.root instanceof Document)throw new Error("Virtualizer.setupElement: Invalid setup method");this.root.addEventListener("scroll",this.handleElementScroll,{passive:!0}),this.resizeObserver?.observe(this.root),r??=this.root.firstElementChild??void 0,r instanceof HTMLElement&&(this.contentContainer=r,this.resizeObserver?.observe(r))}cleanUp(){go(this.computeRenderRangeAndEmit),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.root?.removeEventListener("scroll",this.handleElementScroll),window.removeEventListener("scroll",this.handleWindowScroll),window.removeEventListener("resize",this.handleWindowResize),this.root=void 0,this.contentContainer=void 0,this.observers.clear(),this.visibleInstances.clear(),this.instancesChanged.clear(),this.reconcileQueue.clear(),this.connectQueue.clear(),this.visibleInstancesDirty=!1,this.windowSpecs={top:0,bottom:0},this.scrollTop=0,this.height=0,this.scrollHeight=0,this.scrollDirty=!0,this.heightDirty=!0,this.scrollHeightDirty=!0}getOffsetInScrollContainer(r){return this.getScrollTop()+Kt(r,this.getScrollContainerElement())}connect(r,l){if(this.observers.has(r))throw new Error("Virtualizer.connect: instance is already connected...");return this.intersectionObserver==null?this.connectQueue.set(r,l):(this.intersectionObserver.observe(r),this.observers.set(r,l),this.instancesChanged.add(l),this.markDOMDirty(),$e(this.computeRenderRangeAndEmit)),()=>this.disconnect(r)}disconnect(r){const l=this.observers.get(r);this.connectQueue.delete(r),l!=null&&(this.intersectionObserver?.unobserve(r),this.observers.delete(r),this.instancesChanged.delete(l),this.reconcileQueue.delete(l),this.visibleInstances.delete(r)&&(this.visibleInstancesDirty=!0),this.markDOMDirty(),$e(this.computeRenderRangeAndEmit))}scrollFix(r){if(r==null)return;const l=this.getScrollContainerElement(),{lineIndex:a,lineOffset:c,fileElement:p,fileOffset:b,fileTypeOffset:S}=r;if(a!=null&&c!=null){const F=p.shadowRoot?.querySelector(`[data-line][data-line-index="${a}"]`);if(F instanceof HTMLElement){const G=Kt(F,l);if(G!==c){const h=G-c;this.applyScrollFix(h)}return}}const A=Kt(p,l);if(S==="top")A!==b&&this.applyScrollFix(A-b);else{const F=A+p.getBoundingClientRect().height;F!==b&&this.applyScrollFix(F-b)}}applyScrollFix(r){this.root==null||this.root instanceof Document?window.scrollTo({top:window.scrollY+r,behavior:"instant"}):this.root.scrollTo({top:this.root.scrollTop+r,behavior:"instant"}),this.markDOMDirty()}getScrollAnchor(r){const l=this.getScrollContainerElement();let a;for(const[c]of this.visibleInstances.entries()){const p=Kt(c,l),b=p+c.offsetHeight;let S,A;b<=0?(S=b,A="bottom"):(S=p,A="top");let F,G;if(b>0&&p<r)for(const oe of c.shadowRoot?.querySelectorAll("[data-line][data-line-index]")??[]){if(!(oe instanceof HTMLElement))continue;const Te=oe.dataset.lineIndex;if(Te==null)continue;const ue=Kt(oe,l);if(!(ue<0)){F=Te,G=ue;break}}if(a?.lineOffset!=null&&G==null)continue;let h=!1;(a==null||G!=null&&(a.lineOffset==null||G<a.lineOffset)||G==null&&a.lineOffset==null&&(S>=0&&(a.fileOffset<0||S<a.fileOffset)||S<0&&a.fileOffset<0&&S>a.fileOffset))&&(h=!0),h&&(a={fileElement:c,fileTypeOffset:A,fileOffset:S,lineIndex:F,lineOffset:G})}return a}getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let r=this.root==null?0:this.root instanceof Document?window.scrollY:this.root.scrollTop;return r=this.clampScrollTop(r),this.scrollTop=r,r}scrollTo({top:r,behavior:l="auto"}){const{root:a}=this;if(a==null)return;const c=this.clampScrollTop(r);a instanceof Document?window.scrollTo({top:c,behavior:l}):a.scrollTo({top:c,behavior:l}),this.scrollDirty=!0,$e(this.computeRenderRangeAndEmit)}clampScrollTop(r){return Math.max(0,Math.min(r,this.getScrollHeight()-this.getHeight()))}getScrollHeight(){return this.scrollHeightDirty?(this.scrollHeightDirty=!1,this.scrollHeight=this.root==null?0:this.root instanceof Document?this.root.documentElement.scrollHeight:this.root.scrollHeight,this.scrollHeight):this.scrollHeight}getHeight(){return this.heightDirty?(this.heightDirty=!1,this.height=this.root==null?0:this.root instanceof Document?globalThis.innerHeight:this.root.getBoundingClientRect().height,this.height):this.height}markDOMDirty(){this.scrollDirty=!0,this.scrollHeightDirty=!0,this.heightDirty=!0}getScrollContainerElement(){return this.root==null||this.root instanceof Document?void 0:this.root}},q(Pe,"__STOP",!1),q(Pe,"__lastScrollPosition",0),Pe);function Kt(f,r){const l=f.getBoundingClientRect(),a=r?.getBoundingClientRect().top??0;return l.top-a}var Eo=T('<div class="absolute inset-0 flex items-center justify-center rounded-lg bg-background/60 backdrop-blur-[2px] transition-opacity duration-spring-moderate ease-spring-moderate motion-reduce:transition-none z-10 pointer-events-none"><div class="flex items-center gap-2 rounded-lg border border-border bg-card px-3 py-2 text-xs font-medium text-subtle shadow-lg"><!> </div></div>'),Oo=T("<!> <!>",1),No=T('<div class="flex h-24 items-center justify-start text-left text-subtle"> </div>'),To=T('<div role="region"><!></div>');function Lr(f,r){if(new.target)return dn({component:Lr,...f});gn(r,!0);const l=()=>je(ve,"$sideBySide",a),[a,c]=On(),p=Nn()?.workspaceId??void 0;let b=C(r,"change",7),S=C(r,"foldUnchanged",7,!0),A=C(r,"allowHeadReads",7,!0),F=C(r,"canReadHeadFiles",7),G=C(r,"lineWrapping",7,!1),h=C(r,"scrollToLine",7),oe=C(r,"isAggregate",7,!1),Te=C(r,"showScrollHint",7,!1),ue=C(r,"onStageHunk",7),Q=C(r,"onUnstageHunk",7),at=C(r,"onOpenCommit",7),pt=C(r,"virtualizer",7),vt=C(r,"gitRootId",7,void 0),_t=C(r,"gitRootPath",7,void 0);const ve=kr();let Re=J(!1),Se=J(!1),Fe=J(!1),Ue=J(0),qe=J(void 0);const $=80;function ie(){m(Se,!0)}function De(){m(Se,!1),m(Fe,!1),m(Ue,0)}function Le(v){!e(Se)||e(Re)||(m(Ue,e(Ue)+Math.abs(v.deltaY)),e(Ue)>=$&&!e(Fe)&&m(Fe,!0))}function jt(){m(Re,!0),m(Fe,!1),m(Ue,0)}function qt(v){e(qe)&&!e(qe).contains(v.relatedTarget)&&m(Re,!1)}Be(()=>{(e(Re)||!e(Se))&&(m(Fe,!1),m(Ue,0))});let Lt=u(()=>{const{toolCallId:v,filePath:_e,additions:Qe,deletions:St,oldContent:re,newContent:Xe}=b(),rt="staged"in b()&&b().staged===!0,Ke="category"in b()?b().category:void 0,At="commitHash"in b()?b().commitHash:void 0,zt="gitlink"in b()?b().gitlink:void 0,Mt="isFullFileContent"in b()?b().isFullFileContent:!1;let yt;return Ke==="committed"?yt=an.Committed:rt?yt=an.Staged:yt=an.Unstaged,{id:v,file:_e,relativePath:_e,stage:yt,commitHash:At,gitlink:zt,stats:{additions:Qe,deletions:St},attribution:{timestamp:0},content:re!==void 0||Xe!==void 0?{oldContent:re??"",newContent:Xe??"",isFullFileContent:Mt}:void 0}});const D=u(()=>b().isFullFileContent?1:("chunks"in b()?b().chunks?.[0]?.newStart:void 0)??b().startLineNumber??1);var Ht={get change(){return b()},set change(v){b(v),x()},get foldUnchanged(){return S()},set foldUnchanged(v=!0){S(v),x()},get allowHeadReads(){return A()},set allowHeadReads(v=!0){A(v),x()},get canReadHeadFiles(){return F()},set canReadHeadFiles(v){F(v),x()},get lineWrapping(){return G()},set lineWrapping(v=!1){G(v),x()},get scrollToLine(){return h()},set scrollToLine(v){h(v),x()},get isAggregate(){return oe()},set isAggregate(v=!1){oe(v),x()},get showScrollHint(){return Te()},set showScrollHint(v=!1){Te(v),x()},get onStageHunk(){return ue()},set onStageHunk(v){ue(v),x()},get onUnstageHunk(){return Q()},set onUnstageHunk(v){Q(v),x()},get onOpenCommit(){return at()},set onOpenCommit(v){at(v),x()},get virtualizer(){return pt()},set virtualizer(v){pt(v),x()},get gitRootId(){return vt()},set gitRootId(v=void 0){vt(v),x()},get gitRootPath(){return _t()},set gitRootPath(v=void 0){_t(v),x()},$set:un,$on:(v,_e)=>hn(r,v,_e)},He=To();let wt;var It=N(He);{var Ge=v=>{var _e=Oo(),Qe=ne(_e);{let Xe=u(()=>l()?"split":"unified");Pr(Qe,{get change(){return e(Lt)},get workspaceId(){return p},get viewMode(){return e(Xe)},get foldUnchanged(){return S()},get lineWrapping(){return G()},get onStageHunk(){return ue()},get onUnstageHunk(){return Q()},useProvidedContent:!0,get allowHeadReads(){return A()},get canReadHeadFiles(){return F()},get lineOffset(){return e(D)},get virtualizer(){return pt()},get gitRootId(){return vt()},get gitRootPath(){return _t()}})}var St=y(Qe,2);{var re=Xe=>{var rt=Eo(),Ke=N(rt),At=N(Ke);Ne(At,{get icon(){return ro},class:"w-3 h-3"});var zt=y(At);H(Ke),H(rt),z(Mt=>K(zt,` ${Mt??""}`),[()=>P.chat_inlineDiffItem_clickToScroll_label()]),cn(1,rt,()=>Ws,()=>({tier:"fast",y:0,scale:1})),cn(2,rt,()=>Bs,()=>({tier:"fast"})),w(Xe,rt)};M(St,Xe=>{Te()&&e(Fe)&&Xe(re)})}w(v,_e)},bt=v=>{var _e=No(),Qe=de(_e,!0);z(St=>K(Qe,St),[()=>P.chat_inlineDiffItem_noWorkspace_label()]),w(v,_e)};M(It,v=>{p?v(Ge):v(bt,-1)})}H(He),on(He,v=>m(qe,v),()=>e(qe)),z(v=>{wt=En(He,1,"inline-diff-container relative",null,wt,{focused:e(Re)}),Ve(He,"aria-label",v)},[()=>P.chat_inlineDiffItem_viewer_ariaLabel()]),sn("mouseenter",He,ie),sn("mouseleave",He,De),sn("wheel",He,Le),ln("focusin",He,jt),ln("focusout",He,qt),w(f,He);var mn=fn(Ht);return c(),mn}xr(["focusin","focusout"]);function Sr(f){return[f.stage,f.type,f.oldLineNumber??"",f.newLineNumber??"",f.content].join("\0")}function Do(f){let r=f.oldStart,l=f.newStart;return f.lines.map(a=>{const c={...a,oldLineNumber:a.oldLineNumber??a.oldNumber,newLineNumber:a.newLineNumber??a.newNumber};return c.oldLineNumber===void 0&&c.newLineNumber===void 0?a.type==="Context"?(c.oldLineNumber=r++,c.newLineNumber=l++):a.type==="Deletion"?c.oldLineNumber=r++:a.type==="Addition"&&(c.newLineNumber=l++):a.type==="Context"?(r=(c.oldLineNumber??r)+1,l=(c.newLineNumber??l)+1):a.type==="Deletion"?r=(c.oldLineNumber??r)+1:a.type==="Addition"&&(l=(c.newLineNumber??l)+1),c})}function zo(f,r){const l=f?f.split(`
|
|
2
2
|
`):[],a=r?r.split(`
|
|
3
3
|
`):[];if(l.length===0&&a.length===0)return[];const c=[];for(const p of l)c.push({type:"Deletion",content:p});for(const p of a)c.push({type:"Addition",content:p});return[{oldStart:1,oldLines:l.length,newStart:1,newLines:a.length,lines:c}]}function Mo(f){if(!f||f.length===0)return[];const r=[];for(const a of f){let c=a.change.chunks||[];c.length===0&&(a.change.oldContent!=null||a.change.newContent!=null)&&(c=zo(a.change.oldContent??"",a.change.newContent??"")),c.forEach((p,b)=>{r.push({hunk:p,stage:a.category,part:a,hunkIndex:b})})}if(r.length===0)return[];r.sort((a,c)=>a.hunk.newStart-c.hunk.newStart);const l=[];for(const{hunk:a,stage:c,hunkIndex:p}of r){const S=Do(a).map(A=>({type:A.type,content:A.content,oldLineNumber:A.oldLineNumber,newLineNumber:A.newLineNumber,stage:c,hunkIndex:p}));l.push({headStart:a.oldStart,headLines:a.oldLines,wtStart:a.newStart,wtLines:a.newLines,lines:S,stages:new Set([c])})}return $o(l)}function $o(f){if(f.length<=1)return f;const r=[];let l=f[0];for(let a=1;a<f.length;a++){const c=f[a],p=l.wtStart+l.wtLines;c.wtStart<=p+3?l=Fo(l,c):(r.push(l),l=c)}return r.push(l),r}function Fo(f,r){const l=new Map,a=new Map,c=new Set;for(const h of f.lines)c.add(Sr(h)),h.newLineNumber!==void 0&&l.set(h.newLineNumber,h),h.oldLineNumber!==void 0&&h.type!=="Addition"&&a.set(h.oldLineNumber,h);const p=[...f.lines];for(const h of r.lines){const oe=Sr(h);if(!c.has(oe)){if(h.type==="Context"){const Te=h.newLineNumber!==void 0?l.get(h.newLineNumber):void 0,ue=h.oldLineNumber!==void 0?a.get(h.oldLineNumber):void 0;if(Te?.type==="Context"||ue?.type==="Context"){c.add(oe);continue}}p.push(h),c.add(oe),h.newLineNumber!==void 0&&l.set(h.newLineNumber,h),h.oldLineNumber!==void 0&&h.type!=="Addition"&&a.set(h.oldLineNumber,h)}}p.sort((h,oe)=>{const Te=h.newLineNumber??h.oldLineNumber??0,ue=oe.newLineNumber??oe.oldLineNumber??0;return Te-ue});const b=new Set([...f.stages,...r.stages]),S=Math.min(f.headStart,r.headStart),A=Math.min(f.wtStart,r.wtStart),F=Math.max(f.headStart+f.headLines,r.headStart+r.headLines),G=Math.max(f.wtStart+f.wtLines,r.wtStart+r.wtLines);return{headStart:S,headLines:F-S,wtStart:A,wtLines:G-A,lines:p,stages:b}}function Uo(f){const r=[],l=[];let a=f[0]?.headStart??1,c=f[0]?.wtStart??1;const p=(b,S,A)=>{let F=S;for(;F<A;)b.push(""),F++;return F};for(const b of f){a=p(r,a,b.headStart),c=p(l,c,b.wtStart);for(const S of b.lines)S.type==="Context"?(S.oldLineNumber!==void 0&&(a=p(r,a,S.oldLineNumber)),S.newLineNumber!==void 0&&(c=p(l,c,S.newLineNumber)),r.push(S.content),l.push(S.content),a++,c++):S.type==="Deletion"?(S.oldLineNumber!==void 0&&(a=p(r,a,S.oldLineNumber)),r.push(S.content),a++):S.type==="Addition"&&(S.newLineNumber!==void 0&&(c=p(l,c,S.newLineNumber)),l.push(S.content),c++)}return{oldContent:r.join(`
|
|
4
4
|
`),newContent:l.join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{J5 as s,i7 as a,ma as S,nM as f,mn as m}from"./CI4_aI7e.js";import{v as O}from"./
|
|
1
|
+
import{J5 as s,i7 as a,ma as S,nM as f,mn as m}from"./CI4_aI7e.js";import{v as O}from"./CoZeNthD.js";import{dL as d,b4 as b,dT as k}from"./C2wWLl1x.js";const v=s.createSelector((t,e)=>{if(b.select(t,e)&&k.select(t,e))return!1;const r=t.principal?.snapshot;return r?.capabilities.workspaceGuestRoles===!0&&(r.capabilities.hostMembership?r.principal.hostRole==="guest":!r.principal.isAdministrator)}),h=s.createSelector(t=>t.principal?.snapshot?.capabilities.remoteScripts===1),l=s.createSelector((t,e,r)=>!v.select(t,e)||!!d.select(t,e)&&r?.purpose==="saved");function o(t,e,r){return!!e&&!!r&&l.select(t,e,r)}function i(t,e){return e?t.scripts.byWorkspaceId[e]??m:m}const j=s.createSelector((t,e)=>i(t,e).initialized),W=s.createSelector((t,e)=>{const r=i(t,e);return r.activeScriptIds?r.activeScriptIds.flatMap(c=>o(t,e,r.scripts[c])?[r.scripts[c]]:[]):Object.values(r.scripts).filter(c=>!c.archivedAt&&o(t,e,c))}),C=s.createSelector((t,e)=>W.select(t,e).filter(r=>O((r.runtime??a()).status))),u=s.createSelector((t,e,r)=>{const c=i(t,e);return o(t,e,c.scripts[r])?c.scripts[r]:null}),M=s.createSelector((t,e,r)=>u.select(t,e,r)?.runtime??a()),x=s.createSelector((t,e,r)=>{const c=i(t,e);return l.select(t,e??"",c.scripts[r])?c.outputBuffers[r]??S:S}),E=s.createSelector((t,e,r,c)=>{const n=i(t,e).retainedOutputs?.[c];return n?.scriptId===r&&l.select(t,e,i(t,e).scripts[r])?n:void 0}),z=s.createSelector(t=>Object.entries(t.scripts?.byWorkspaceId??{}).filter(([,e])=>Object.keys(e.retainedOutputs??{}).length>0).map(([e])=>e).sort()),A=s.createSelector((t,e)=>!!t.scripts?.byWorkspaceId[e]?.outputStreamReady),D=s.createSelector((t,e)=>i(t,e).initialized),B=s.createSelector((t,e)=>{const r=i(t,e);return r.activeScriptIds?r.activeScriptIds.flatMap(c=>o(t,e,r.scripts[c])?[r.scripts[c]]:[]):Object.values(r.scripts).filter(c=>!c.archivedAt&&o(t,e,c))}),G=s.createSelector((t,e)=>{const r=i(t,e);return r.detectionOperation?.pending?{...r.operations,...Object.fromEntries(Object.keys(r.scripts).map(c=>[c,r.detectionOperation]))}:r.operations}),L=s.createSelector((t,e)=>i(t,e).detectionOperation),J=s.createSelector((t,e,r,c)=>{const n=i(t,r).workflowOutcomes,p=n?f(n,e):void 0;return p?.workspaceId===r&&p.resourceId===c?p:void 0}),P=s.createSelector((t,e,r)=>u.select(t,e,r)?.runtime??a()),T=s.createSelector((t,e)=>Object.values(i(t,e).scripts).filter(r=>o(t,e,r))),U=s.createSelector((t,e,r)=>i(t,e).pendingReads?.[r]),V=s.createSelector((t,e,r)=>!!u.select(t,e,r)&&!i(t,e).detectionOperation?.pending&&!i(t,e).operations[r]?.pending),q=s.createSelector((t,e)=>({nextCursor:i(t,e).nextCursor,loading:i(t,e).loading,error:i(t,e).loadError}));export{T as selectAllWorkspaceScriptEntries,V as selectCanDeleteScript,l as selectCanReadScriptDefinition,h as selectRemoteScriptsSupported,C as selectRunningScripts,u as selectScriptById,L as selectScriptDetectionOperation,W as selectScriptEntries,q as selectScriptListPageState,x as selectScriptOutput,A as selectScriptOutputStreamReady,z as selectScriptOutputViewerWorkspaceIds,U as selectScriptReadJournal,E as selectScriptRetainedOutput,M as selectScriptRuntime,J as selectScriptWorkflowOutcome,j as selectScriptsInitialized,v as selectUsesGuestScriptScope,B as selectWorkspaceScriptEntries,G as selectWorkspaceScriptOperations,P as selectWorkspaceScriptRuntime,D as selectWorkspaceScriptsInitialized};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as B,bo as f,bw as T,bq as W,b as j,bm as q,bs as z}from"./51_h0jm2.js";import{bs as D,cd as E,ca as L,a7 as O,ay as F,W as d,bn as G,aA as h,aD as t,c9 as r,a5 as H,bl as J,bA as K,b_ as M,bO as N,aB as Q}from"./CJxGDkBm.js";import{i as R}from"./PXCFrn2V.js";import{C as U}from"./
|
|
1
|
+
import{t as B,bo as f,bw as T,bq as W,b as j,bm as q,bs as z}from"./51_h0jm2.js";import{bs as D,cd as E,ca as L,a7 as O,ay as F,W as d,bn as G,aA as h,aD as t,c9 as r,a5 as H,bl as J,bA as K,b_ as M,bO as N,aB as Q}from"./CJxGDkBm.js";import{i as R}from"./PXCFrn2V.js";import{C as U}from"./BpcFcSgh.js";import{dE as V}from"./C2wWLl1x.js";import{i as X}from"./H2jLkRRS.js";var Y=Q('<div class="flex flex-col items-center justify-center h-full text-subtle gap-4"><p class="text-sm"> </p></div>');function Z(c,o){if(new.target)return B({component:Z,...c});D(o,!0);const l=()=>z(b,"$workspace",m),[m,u]=W();let s=f(o,"tab",7),n=f(o,"workspaceId",7);const i=E(n());L(()=>{i.set(n())});const b=V(i),_=r(()=>l()?.worktreePath||l()?.repositoryPath||""),g=r(()=>s().data?.changes||[]),v=r(()=>s().data?.isAggregate||!1),w=r(()=>s().data?.agentId),k=r(()=>t(g).map(e=>{const a=e.filePath&&X(e.filePath)?e.filePath:`${t(_)}/${e.filePath}`;return{...e,filePath:a}}));var C={get tab(){return s()},set tab(e){s(e),h()},get workspaceId(){return n()},set workspaceId(e){n(e),h()},$set:T,$on:(e,a)=>j(o,e,a)},p=O(),y=F(p);{var P=e=>{U(e,{isLoading:!1,get changes(){return t(k)},get isAggregate(){return t(v)},get agentId(){return t(w)},showStagingControls:!0})},I=e=>{var a=Y(),A=H(a),$=J(A,!0);K(a),M(S=>N($,S),[()=>q.layout_chatChanges_noChanges_label()]),d(e,a)};R(y,e=>{t(g).length>0?e(P):e(I,-1)})}d(c,p);var x=G(C);return u(),x}export{Z as default};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["/app/immutable/chunks/
|
|
2
|
-
var Ct=Object.defineProperty;var Dt=(e,t,n)=>t in e?Ct(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Pe=(e,t,n)=>Dt(e,typeof t!="symbol"?t+"":t,n);import{J5 as A,i as be,nM as R,wc as Rt,C9 as Ge,we as xt,Dm as Je,cE as Pt,cF as Bt,nN as Ye,nz as Ot,e as ke,fM as $t,l_ as Ut,cM as Lt}from"./CI4_aI7e.js";import{J as Nt,Z as Ht,dT as Be,cR as pe,dE as Ft,aw as Kt,bc as Qe,I as Wt,e4 as jt}from"./C2wWLl1x.js";import{e as qt,b as ae,F as Vt,y as re,_ as ve,G as zt,C as Gt,W as Xe,v as Jt,u as Yt,M as Qt}from"./BEklUrxK.js";import{D as Oe,a as Xt,d as Zt}from"./CQcEqK4G.js";import{m as en,g as Ze,r as tn,k as nn,D as an}from"./1q0xL14K.js";import{e as rn}from"./CL3a4Hm1.js";import{z as et,O as sn}from"./Bqd7fdCF.js";import{a as on}from"./Dz5-AChV.js";import{f as cn}from"./CQkTODWA.js";import{bm as b,_ as fe}from"./51_h0jm2.js";import{aa as tt,aB as se,J as he,a as nt,n as at,cS as rt,e as st,aI as it,M as ln,ac as dn,aV as $e,d as le,C as un,cT as mn,U as pn,a6 as fn,aJ as hn,b_ as gn}from"./DqMtaSxK.js";import{W as yn,L as wn,w as bn,R as kn,M as vn,h as _n}from"./rIUowGAi.js";import{l as q,i as Sn,n as Mn}from"./DqFWZ_g1.js";import{x as An,J as In,ai as Tn,ar as En}from"./DqZnld6x.js";import{a as Ue,b as Cn,g as Dn}from"./DypB-Dwi.js";import{m as Rn}from"./CAV1CzzW.js";import{C as xn}from"./B5aYN90J.js";import{i as Pn}from"./BZWU4mlm.js";import{o as $,e as Bn,l as V,s as E,n as ce,b as On,d as $n,c as Un}from"./CIyUrgF0.js";const Rr=A.createSelector((e,t)=>e.unreadTracking.dividerSessionByAgentId[t]??null),xr=A.createSelector(e=>e.unreadTracking.currentlyViewedAgentId),Pr=A.createSelector(e=>{const t=[];for(const s of Object.values(e.panelLayout.byWorkspaceId))for(const i of Object.values(s.panels))for(const o of i.tabs)o.type==="agent"&&o.agentId&&t.push(o.agentId);const n=Object.keys(e.unreadTracking.dividerSessionByAgentId),a=new Set(e.agentSessions.agentIdsByWorkspace[be]??[]);return{chiefCardVisible:e.sidebarNav.panelItem==="chief",chiefSessionAgentIds:n.filter(s=>a.has(s)),dividerSessionAgentIds:n,openAgentTabIds:t}});function Br(e,t){if(e)return e.model}function Ln({messages:e,pendingInitialPrompt:t,pendingContextReferenceCount:n=0}){return e.length>0||!!t||n>0}function Or({session:e,messages:t,pendingInitialPrompt:n,pendingContextReferenceCount:a=0}){return!(e?Nt(e):!1)&&!Ln({messages:t,pendingInitialPrompt:n,pendingContextReferenceCount:a})}function $r(e){return Ht(e.messageMetadata)}function Nn(e){return{id:e.id,appMessageId:e.appMessageId,role:"user",timestamp:new Date(e.createdAt??0).toISOString(),contentBlocks:[...e.content?[{type:"text",text:e.content}]:[],...e.imageBlocks??[],...e.fileBlocks??[]],metadata:e.messageMetadata,...e.author!==void 0?{author:e.author}:{}}}function Ur(e){return Nn({...e,createdAt:Date.parse(e.queuedAt)})}const Hn=8*1024*1024,Fn=3*1024*1024;function Kn(e){return Math.ceil(Math.max(0,e)/3)*4}function Wn(e){const t=e.promptBase64Bytes;return e.mimeType==="image/jpeg"&&Number.isSafeInteger(e.size)&&e.size>0&&e.size<=Fn&&typeof t=="number"&&t===Kn(e.size)?t:null}async function ot(e,t,n,a,r=()=>{}){const s=()=>{if(!a())throw new Error("media-send-retired")};if(s(),r("overlay-render"),!n.exportMedia)throw new Error("media-export-unavailable");const i=on(e.source,e.saved);if(i.length>1e4)throw new Error("media-animation-layer-limit");const o=[];for(const c of i)s(),o.push({...c,png:await en(e.source,e.saved,c.atMs)});s(),r("export");const l=await n.exportMedia({outputVersion:qt,jobId:t,media:e,layers:o});if(s(),!l.ok)throw new Error(["media-export-failed",l.error].filter(Boolean).join(":"));return{jobId:t,value:l.value}}const _e={CLIPBOARD_WRITE:"dock-media:clipboard-write",CLIPBOARD_READ:"dock-media:clipboard-read",MENU:"dock-media:menu"};function Le(e,t){return Math.max(0,(e.pausedAt??t)-e.startedAt-(e.pausedMs??0))}function ge(e,t){if(!t?.startsWith(".intent/attachments/"))return;const n=t.split("/").map(encodeURIComponent).join("/"),a=tt(`intent://local/file/${n}`,e);return a?.kind==="video"?a.url:void 0}function jn(e){const t=e.video==="full"?b.dock_captureEditor_videoFull_label():b.dock_captureEditor_videoHighlights_label(),n=e.voice==="audio"?b.dock_captureEditor_voiceAudio_label():e.voice==="transcript"?b.dock_captureEditor_voiceTranscript_label():b.dock_captureEditor_voiceOff_summary();return`${t} · ${n}`}function qn(e,t,n,a){if(a?.error==="permission")return a.kind==="pick"?"accessibility":"screen";if(e==="permission"||t==="permission")return"screen";if(n?.startsWith("microphone-permission"))return"microphone";if(n?.startsWith("speech-permission"))return"speech"}const j=cn;function Lr(e){const{view:t,items:n,local:a,labels:r,copy:s}=e,i=t.speech.error??t.speech.capability?.reason??null,o=qn(t.captureError,t.clips.find(g=>g.status==="failed"&&g.error==="permission")?.error??null,i,t.annotationIssue),l=t.annotationIssue?.error==="unavailable"?s?.annotationUnavailable:void 0,c=t.annotationIssue,d=t.captureError==="permission",u=c?.error==="permission"&&c.kind!=="pick",h=c?.error==="permission"&&c.kind==="pick",p=i?.startsWith("speech-permission")?"speech":i?.startsWith("microphone-permission")||i==="permission"?"microphone":void 0,m={},y={},f=(g,D,L)=>{m[g]=D,L&&(y[g]=L)};s&&(d&&(f("capture",s.permission,"screen"),t.recording||f("record",s.permission,"screen")),u&&!t.annotating&&f("annotate",s.permission,"screen"),h&&(f("pick",s.accessibilityPermission,"accessibility"),t.tool==="pick"&&!t.annotating&&f("annotate",s.accessibilityPermission,"accessibility")),p&&!t.dictation&&f("mic",(i&&r.speechError?.(i))??s.speechPermission,p));const k=g=>{const D=y[g];D&&e.actions.onOpenSettings(D)},v=new Set(t.evidenceOwnedItemIds),I=t.clips.find(g=>g.status==="recording"),S=t.clips.length>=ae.clips,_=t.capabilities,B=t.speech.available,C=new Set(t.clips.filter(g=>g.status==="recording"||g.status==="placing"||!!g.media).flatMap(g=>g.captureHistory?.map(D=>D.image.id)??[])),P=[...t.tiles.filter(({image:g,marks:D})=>!!g.media||g.source!=="annotate"||!C.has(g.id)||D.some(({mark:L})=>!L.clipId)).map(({image:g,marks:D})=>({kind:"image",id:g.contextItemId,url:a.previews[g.id]??"",markCount:D.length,owner:"evidence",...a.previews[g.id]?{}:{status:"placing"}})),...t.clips.filter(g=>!g.discarding).map(g=>({kind:"clip",id:g.contextItemId??g.id,duration:j(g.status==="recording"?Le(g,a.now):g.durationMs),recording:g.status==="recording",...g.media?.saved?{summary:jn(g.media.saved)}:{},...g.status==="ready"&&ge(e.workspaceId,g.path)?{url:ge(e.workspaceId,g.path)}:{},owner:"evidence",...g.status==="placing"?{status:"placing"}:{},...g.status==="failed"?{status:"failed",...g.error==="limit"?{error:b.dock_composer_clipTooLarge_error()}:{}}:{}})),...n.filter(g=>!v.has(g.id)).map(g=>({...g.imageData&&g.imageMimeType?{kind:"image",id:g.id,url:`data:${g.imageMimeType};base64,${g.imageData}`,markCount:0,file:{name:g.label,imageData:g.imageData,imageMimeType:g.imageMimeType}}:{kind:"file",id:g.id,name:g.label},owner:"attachment",...g.placementStatus==="placing"?{status:"placing"}:{},...g.placementStatus==="failed"?{status:"failed",error:g.placementError}:{}}))];return{mediaStatus:t.recording?{kind:"recording",label:r.recording}:t.annotating?{kind:"annotating",label:r.annotating}:void 0,...o?{settingsPane:o}:{},...l?{annotationNotice:l}:{},labels:r,attachments:P,...s?{placeholder:t.dictation?"":s.idle}:{},state:{captureRevision:t.captureAccepted,capturePending:t.capturePending,captureDisabled:!_.capture||t.captureDisabled,...t.captureDisabled?{captureTooltip:r.captureLimit}:{},captureMode:t.evidence?.annotation?"fullscreen":t.captureMode,captureModesAvailable:!!_.captureModes&&!t.evidence?.annotation,annotationActive:t.annotating,tool:t.tool,toolUsed:t.toolUsed,annotationDisabled:!_.annotate,recording:t.recording&&!I?.discarding,recordingDisabled:!!I?.discarding||!t.recording&&(!_.record||S),...S&&!t.recording?{recordingTooltip:r.clipLimit}:{},recordingTime:j(I?Le(I,a.now):0),dictating:!!t.dictation,dictationPending:t.speech.pending||t.dictation?.status==="transcribing",dictationDisabled:!B&&!t.dictation&&!m.mic,...t.speech.error&&r.speechError?{dictationTooltip:r.speechError(t.speech.error)}:{},dictationTime:t.dictation?j(a.now-t.dictation.startedAt):j(0),inputLevels:t.speech.levels,...Object.keys(m).length?{alerts:m}:{}},...e.actions,...t.fileAttachmentsEnabled===!1?{onEdit:void 0}:{},onAlert:k,beforeSubmit:e.beforeSubmit}}const Se=()=>globalThis.electronAPI,Vn=["image/png","image/jpeg","image/webp"],Ne=e=>Vn.includes(e??"")?e:null;function He(e){const t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;a+=1)n[a]=t.charCodeAt(a);return n}async function Nr(e,t){const{view:n,items:a,previews:r}=t,s=n.tiles.find(({image:c})=>c.id===e||c.contextItemId===e);if(s){const c=a.find(p=>p.id===s.image.contextItemId),d=s.image.media;if(s.image.mediaError)return null;if(d?.saved){if(!t.createSavedPreviewUrl||!t.revokeUrl)return null;const p={...d,saved:d.saved},m=await t.createSavedPreviewUrl(t.workspaceId,p);try{const y=await t.fetchBytes(m),f=p.saved.crop;return{kind:"image",name:c?.label||"screenshot.png",mimeType:"image/png",bytes:y,intent:{pixels:{mimeType:"image/png",width:Math.max(1,Math.round(f?.w??p.source.width)),height:Math.max(1,Math.round(f?.h??p.source.height)),displayScale:s.image.displayScale,capturedAt:s.image.capturedAt},raw:y,marks:[]}}}finally{t.revokeUrl(m)}}const u=Ne(c?.imageMimeType),h=r[s.image.id];return!c?.imageData||!u||!h?null:{kind:"image",name:c.label||"screenshot.png",mimeType:"image/png",bytes:await t.fetchBytes(h),intent:{pixels:{mimeType:u,width:s.image.width,height:s.image.height,displayScale:s.image.displayScale,capturedAt:s.image.capturedAt,...s.image.hash?{hash:s.image.hash}:{}},raw:He(c.imageData),marks:s.marks.map(({mark:p})=>({tool:p.tool,geometry:p.geometry,bounds:p.bounds,element:p.element}))}}}const i=n.clips.find(c=>c.id===e||c.contextItemId===e);if(i){const c=i.status==="ready"?ge(t.workspaceId,i.path):null;if(!c)return null;const d=a.find(h=>h.id===i.contextItemId),u=await t.fetchBytes(c);if(!Gn(u))throw new Error("Not a recording file");return{kind:"clip",name:d?.label||`recording-${i.id.slice(0,8)}.mp4`,mimeType:d?.attachmentMimeType||"video/mp4",bytes:u,durationMs:i.durationMs,hasMicAudio:i.hasMicAudio}}const o=a.find(c=>c.id===e),l=Ne(o?.imageMimeType);return o?.imageData&&l?{kind:"image",name:o.label||"image",mimeType:l,bytes:He(o.imageData)}:null}async function zn(e){const t=await fetch(e);if(!t.ok)throw new Error(`Media request failed (${t.status})`);const n=new Uint8Array(await t.arrayBuffer()),a=Number(t.headers.get("content-length")??Number.NaN);if(n.byteLength===0||Number.isFinite(a)&&a!==n.byteLength)throw new Error("Media response was incomplete");return n}function Gn(e){return e.byteLength>8&&String.fromCharCode(...e.subarray(4,8))==="ftyp"}async function Hr(e){try{return(await Se()?.invoke(_e.CLIPBOARD_WRITE,e))?.ok===!0}catch{return!1}}async function Jn(){try{return await Se()?.invoke(_e.CLIPBOARD_READ,{})??null}catch{return null}}async function Fr(e){try{const t=await Se()?.invoke(_e.MENU,{canCut:e});return t?.action==="copy"||t?.action==="cut"?t.action:null}catch{return null}}const Fe=new WeakSet;async function Yn(e,t){const[n]=e;if(e.length!==1||!n||n.size!==t.size)return!1;try{const a=await crypto.subtle.digest("SHA-256",await n.arrayBuffer());return Array.from(new Uint8Array(a),s=>s.toString(16).padStart(2,"0")).join("")===t.sha256}catch{return!1}}function Kr(e,{onIntentMedia:t,isCurrent:n,read:a=Jn}){const r=e.clipboardData;if(Fe.has(e)||!r||r.files.length===0)return!1;const s=e.target,i=Array.from(r.files),o=r.types.filter(l=>l!=="Files").map(l=>[l,r.getData(l)]);return e.preventDefault(),e.stopImmediatePropagation(),a().catch(()=>null).then(async l=>{if(!n())return;if(l&&await Yn(i,l)){n()&&t(l);return}if(!n()||!(s instanceof Node)||!s.isConnected)return;const c=new DataTransfer;for(const u of i)c.items.add(u);for(const[u,h]of o)c.setData(u,h);const d=new ClipboardEvent("paste",{clipboardData:c,bubbles:!0,cancelable:!0});Fe.add(d),s.dispatchEvent(d)}),!0}function Qn(e){const t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;a++)n[a]=t.charCodeAt(a);return n}function Xn(e){let t="";for(let a=0;a<e.length;a+=32768)t+=String.fromCharCode(...e.subarray(a,a+32768));return btoa(t)}function ct(e){let t=0;return e.endsWith("==")?t=2:e.endsWith("=")&&(t=1),Math.floor(e.length*3/4)-t}async function Zn(e){const t=await crypto.subtle.digest("SHA-256",e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength));return Array.from(new Uint8Array(t)).map(n=>n.toString(16).padStart(2,"0")).join("")}const lt={placeAttachment:it,beginAttachmentUpload:st,sendAttachmentUploadChunk:rt,commitAttachmentUpload:at,abortAttachmentUpload:nt,getAttachmentInfo:he,mintIdempotencyKey:se};async function Me(e,t,n,a=lt){const{idempotencyKey:r}=n,s={...r!==void 0?{idempotencyKey:r}:{},...n.rawScreenshot!==void 0?{rawScreenshot:n.rawScreenshot}:{}},i=async m=>mn(m,r)?$e(e,r,a.getAttachmentInfo):void 0;if(ct(n.data)<=ln)try{return await a.placeAttachment(e,t,{data:n.data,mimeType:n.mimeType,...s})}catch(m){const y=await i(m);if(y)return y;throw m}const o=Qn(n.data),l=await Zn(o);let c,d;try{({uploadId:c,maxChunkBytes:d}=await a.beginAttachmentUpload(e,t,o.byteLength,l,{mimeType:n.mimeType,...s}))}catch(m){if(r!==void 0&&dn(m)){const y=await $e(e,r,a.getAttachmentInfo);if(y)return y}throw m}const u=Math.min(pn,d),h=Math.ceil(o.byteLength/u);let p=!1;try{for(let m=0;m<h;m++){const y=o.subarray(m*u,(m+1)*u);await a.sendAttachmentUploadChunk(c,m,Xn(y),e)}return p=!0,await a.commitAttachmentUpload(c,e)}catch(m){const y=p?await i(m):void 0;if(y)return y;throw await a.abortAttachmentUpload(c,e).catch(()=>{}),m}}function ea(e,t){return fn(e,`image-${Date.now()}-${t+1}`)}class Ae extends Error{constructor(n,a){super(n);Pe(this,"retryBlocks");this.name="ImagePlacementError",this.retryBlocks=a}}function ta(e,t){return e instanceof Ae?e.retryBlocks:t}async function na(e,t,n=lt,a=()=>!0){const r=l=>(...c)=>(le(a),l(...c));n={placeAttachment:r(n.placeAttachment),beginAttachmentUpload:r(n.beginAttachmentUpload),sendAttachmentUploadChunk:r(n.sendAttachmentUploadChunk),commitAttachmentUpload:r(n.commitAttachmentUpload),abortAttachmentUpload:r(n.abortAttachmentUpload),getAttachmentInfo:r(n.getAttachmentInfo),mintIdempotencyKey:r(n.mintIdempotencyKey)};const s=[],i=[],o=[];for(let l=0;l<t.length;l++){le(a);const c=t[l];if("attachmentId"in c&&c.attachmentId){const p={type:"image",attachmentId:c.attachmentId,...c.mimeType?{mimeType:c.mimeType}:{}};s.push(p),i.push(p);continue}const d=c,u=d.placementFileName??ea(d.mimeType,l),h=n.mintIdempotencyKey(d.placementIdempotencyKey);try{const p=await Me(e,u,{data:d.data,mimeType:d.mimeType,...h!==void 0?{idempotencyKey:h}:{}},n),m={type:"image",attachmentId:p.attachmentId,...p.mimeType??d.mimeType?{mimeType:p.mimeType??d.mimeType}:{}};s.push(m),i.push(m)}catch(p){const m=un(p);o.push(m?`${u} (${m})`:u),i.push(h!==void 0?{...d,placementIdempotencyKey:h,placementFileName:u}:d)}}if(o.length>0)throw new Ae(b.chat_imagePlacement_failed_error({names:o.join(", ")}),i);return le(a),s}const Wr=Object.freeze(Object.defineProperty({__proto__:null,ImagePlacementError:Ae,base64DecodedBytes:ct,imageRetryBlocks:ta,placeImageAttachment:Me,toImageReferenceBlocks:na},Symbol.toStringTag,{value:"Module"}));function dt(){try{return yn()}catch{return null}}function aa(){return{backendId:A.state.connections.windowBackendId??null,generation:A.state.daemonHealth.connectionGeneration,transport:dt()}}class Ie extends Error{constructor(){super("dock-evidence-backend-changed")}}function N(e,t){return async(...n)=>{e();const a=await t(...n);return e(),a}}const H={current:e=>dt()===e.transport&&A.state.daemonHealth.connectionGeneration===e.generation&&(A.state.connections.windowBackendId??null)===e.backendId,capabilities:()=>wn(),placeImage:(e,t,n,a)=>Me(e,t,n,{placeAttachment:N(a,it),beginAttachmentUpload:N(a,st),sendAttachmentUploadChunk:N(a,rt),commitAttachmentUpload:N(a,at),abortAttachmentUpload:N(a,nt),getAttachmentInfo:N(a,he),mintIdempotencyKey:se}),lookup:(e,t)=>he({workspaceId:e,idempotencyKey:t}),mintKey:se};function G(e){return H.current(e)}function ra(e,t){const n=A.state.dockConversation;return{generation:n.generation,authority:n.authority,clearRevision:R(n.drafts,Vt(e,t))?.clearRevision??0,binding:aa()}}function jr(e,t,n){const a=ra(e,t);return a.generation===n.generation&&a.authority===n.authority&&a.clearRevision===n.clearRevision&&G(n.binding)}function ut(e,t){return()=>{if(!e.current(t))throw new Ie}}const mt=Object.freeze({rawRetention:!1,chiefAttachments:!1});function qr(e){return e!==mt}const de=new Map;function pt(e,t=H){const n=`${e.backendId}:${e.generation}`;let a=de.get(n);if(!a){const r=ut(t,e);a=(async()=>{r();const i=await t.capabilities();r();const o=i?.server?.capabilities;if(!o||typeof o!="object")throw new Error("unobserved");return{rawRetention:o.rawScreenshotRetention===1,chiefAttachments:o.chiefAttachments===1}})().catch(()=>(de.delete(n),mt)),de.set(n,a)}return a}class Z extends Error{constructor(t){super(`dock-raw-retention-contract:${t}`),this.reason=t}}function ft(e){const{rpcCode:t,code:n}=e??{};return t===-32602||n==="INVALID_PARAMS"}function sa(e){const t=String(e?.message??"");return ft(e)&&(t.includes("rawScreenshotExpired:")||/expired at .*not renewable/i.test(t))}function ia(e,t,n){const a=e.rawScreenshot;if(!a||a.compositeAttachmentId!==t)return null;const r=Date.parse(a.expiresAt);return Number.isFinite(r)?a.expired||r<=n?"expired":{attachmentId:e.attachmentId,expiresAt:a.expiresAt}:null}function Ke(e){return{ok:!0,path:e.path,fileName:e.fileName,size:e.size,attachmentId:e.attachmentId,...e.mimeType?{mimeType:e.mimeType}:{},uploadedAt:e.uploadedAt,replayed:!0,...e.rawScreenshot?{rawScreenshot:e.rawScreenshot}:{}}}class oa extends Error{constructor(t,n){super("dock-evidence-placement-failed"),this.imageId=t,this.failure=n}}const We=e=>e.split("/")[1]?.replace("jpeg","jpg")||"png";async function ca(e){const t=e.api??H,n=e.now??Date.now,a=ut(t,e.binding);a();const r=await pt(e.binding,t);a();const s=r.rawRetention&&(e.workspaceId!==be||r.chiefAttachments),i=[];for(const o of e.images){const l=e.records[o.image.id];let c=l&&l.signature===o.signature&&l.workspaceId===e.workspaceId&&l.backendId===e.binding.backendId?l:{imageId:o.image.id,signature:o.signature,workspaceId:e.workspaceId,backendId:e.binding.backendId,compositeKey:null,rawKey:null,composite:null,raw:null,rawSettled:!1};const d=u=>{c=u,e.onRecord(u)};try{if(!c.composite){const h=c.compositeKey,p=t.mintKey(h??void 0)??null;p!==c.compositeKey&&d({...c,compositeKey:p});let m;h&&p===h&&(a(),m=await t.lookup(e.workspaceId,p).then(Ke).catch(()=>{}),a()),m||(a(),m=await t.placeImage(e.workspaceId,`screenshot-${o.image.id.slice(0,8)}.${We(o.composite.mimeType)}`,{data:o.composite.base64,mimeType:o.composite.mimeType,...p?{idempotencyKey:p}:{}},a),a()),d({...c,composite:{attachmentId:m.attachmentId,mimeType:m.mimeType??o.composite.mimeType}})}const u=c.composite.attachmentId;if(s&&o.raw&&!c.raw&&!c.rawSettled){const h=c.rawKey,p=t.mintKey(h??void 0);if(p){p!==c.rawKey&&d({...c,rawKey:p});let m;h&&p===h&&(a(),m=await t.lookup(e.workspaceId,p).then(Ke).catch(()=>{}),a());try{m||(a(),m=await t.placeImage(e.workspaceId,`screenshot-${o.image.id.slice(0,8)}-original.${We(o.raw.mimeType)}`,{data:o.raw.base64,mimeType:o.raw.mimeType,idempotencyKey:p,rawScreenshot:{compositeAttachmentId:u}},a),a());const y=ia(m,u,n());if(y==="expired")d({...c,rawSettled:!0});else if(y)d({...c,raw:y});else throw new Z("echo")}catch(y){if(sa(y))d({...c,rawSettled:!0});else throw y instanceof Z?y:ft(y)?new Z("refused"):y}}else throw new Z("unkeyed")}}catch(u){throw u instanceof Ie?u:new oa(o.image.id,u)}i.push(c)}return i}async function Vr(e,t,n,a){const r=()=>{if(!H.current(a))throw new Ie};r();const s=await H.placeImage(e,t,{...n,idempotencyKey:H.mintKey()},r);return r(),s}const la=new Set(["invalid-saved-edit","media-send-retired","transcript-unavailable","transcript-pending","invalid-edit","stale-source","legacy-baked-marks","timing-unavailable","audio-unavailable","media-source-unavailable","media-export-unavailable","media-animation-layer-limit","media-export-failed","legacy-original-unavailable","capture-render-unavailable","capture-blur-unavailable","stale-source-pixels","not-a-screenshot","not-admitted","unavailable","dock-evidence-missing-pixels","draft-restore-failed","image-budget-exceeded"]),da=new Set(["unavailable","permission","failed","busy","cancelled","limit"]);class O extends Error{constructor(t,n){super(n),this.stage=t,this.code=n,this.name="DockSendError"}}function ie(e){const t=e instanceof Error?e.message:typeof e=="string"?e:"";if(t.length>64)return"unclassified";const[n,...a]=t.split(":");return!la.has(n)||a.length>2?"unclassified":n!=="media-export-failed"?a.length?"unclassified":n:[n,...a.map(r=>da.has(r)?r:"other")].join(":")}function zr(e,t){return e instanceof O?{stage:e.stage,code:ie(e.code)}:{stage:t,code:ie(e)}}function F(e){if(!e||e.source.kind!=="recording")return!1;const t=e.source,n=e.saved??re(t,t.capturedMarks??[],e.transcript);if(n.video!=="full"||n.voice!=="audio"||n.crop||n.blurRegions.length||n.blurStrokes?.length)return!1;const a=ve(n,t,e.transcript);return t.visuals==="clean"?!a.errors.length&&!a.muted&&n.cuts.length===0&&!n.marks.some(r=>r.included)&&a.marks.length===0&&a.transcript===null&&a.kept.length===1&&a.kept[0].startMs===0&&a.kept[0].endMs===t.durationMs&&a.clips.length===1&&a.clips[0].startMs===0&&a.clips[0].endMs===t.durationMs:!a.errors.length&&!a.muted&&a.clips.length===1&&a.clips[0].startMs===0&&a.clips[0].endMs>=t.durationMs}async function ua(e,t,n,a,r,s){const i={images:{},files:[],frames:[],framePromptBytes:[],metadata:[]};let o="validate";try{const l=()=>{if(!r()||!G(n))throw new Error("media-send-retired")};for(const c of[...t.images,...t.clips]){if(o="validate",s?.stage(o),c.mediaError)throw new Error("invalid-saved-edit");if(!c.media||F(c.media))continue;l();const d=structuredClone(c.media),u=d.source;let h=d.saved??re(u,u.capturedMarks??[],d.transcript),p=crypto.randomUUID();try{if(u.kind==="recording"&&h.voice==="transcript"&&d.transcript?.status!=="ready"){if(o="transcribe",s?.stage(o),!a?.transcribeMedia)throw new Error("transcript-unavailable");const f=await a.transcribeMedia({jobId:p,media:d});if(l(),!f.ok)throw new Error("transcript-unavailable");d.transcript=f.value,d.saved||(h=re(u,u.capturedMarks??[],d.transcript))}o="plan",s?.stage(o);const m=ve(h,u,d.transcript);if(m.errors.length)throw new Error(m.errors[0]);const y={id:c.id,kind:u.kind,video:h.video,voice:h.voice,transcript:m.transcript,batches:u.batches,marks:m.marks.map(({n:f,mark:k,frameAtMs:v})=>({n:f,id:k.id,at_ms:v,kind:k.kind,label:k.label,note:k.note,context:k.context,geometry:k.geometry}))};if(u.kind==="screenshot"){o="screenshot-source",s?.stage(o);const f=u.path.split("/").map(encodeURIComponent).join("/"),k=tt(`intent://local/file/${f}`,e);if(!k||k.kind!=="image")throw new Error("media-source-unavailable");const v=await zn(k.url);l();const I={base64:Ze(v.buffer.slice(v.byteOffset,v.byteOffset+v.byteLength)),mimeType:/\.jpe?g$/i.test(u.path)?"image/jpeg":/\.webp$/i.test(u.path)?"image/webp":"image/png"};o="screenshot-render",s?.stage(o),i.images[c.id]=await tn(u,h,I),l()}else{if(!m.clips.length){y.video_attachment_id=null,y.frames=[],y.kept_ms=[],i.metadata.push(y);continue}const f={...d,saved:h};let k=await a?.takePreparedRecording?.(f);if(k&&(p=k.jobId),l(),!k){if(!a)throw new Error("media-export-unavailable");k=await ot(f,p,a,()=>r()&&G(n),S=>{o=S,s?.stage(S),S==="export"&&s?.exportAttempt(p)})}p=k.jobId,o="placement",s?.stage(o);const v=[k.value.video,...k.value.frames],I=[];for(let S=0;S<v.length;S++){l();const _=v[S],B=`capture-${c.id.slice(0,12)}-${S}.${S===0?"mp4":_.mimeType==="image/jpeg"?"jpg":"png"}`,C=await hn(e,B,{sourcePath:_.sourcePath,mimeType:_.mimeType,idempotencyKey:se()},void 0,void 0,()=>r()&&G(n));l(),S===0?i.files.push({type:"file",attachmentId:C.attachmentId,fileName:B,mimeType:C.mimeType??_.mimeType,size:C.size}):(i.frames.push({type:"image",attachmentId:C.attachmentId,mimeType:_.mimeType==="image/jpeg"?"image/jpeg":"image/png"}),i.framePromptBytes.push(Wn(_))),I.push(C.attachmentId)}y.video_attachment_id=I[0],y.frames=k.value.frames.map((S,_)=>({mark_id:S.markId,attachment_id:I[_+1]})),y.kept_ms=m.clips}i.metadata.push(y)}finally{s?.stage("release"),await a?.releaseMediaJob?.(p).catch(()=>{})}}return i}catch(l){throw l instanceof O?l:new O(o,ie(l))}}const ue=1568,ma=.85;async function pa(e,t){const n=Math.round(e.length*3/4/1024),a=await fa(e,t),{width:r,height:s}=a,i=r>ue||s>ue;let o=r,l=s;if(i){const f=ue/Math.max(r,s);o=Math.round(r*f),l=Math.round(s*f)}const c=new OffscreenCanvas(o,l),d=c.getContext("2d");if(!d)throw new Error("Failed to get 2D canvas context for image resize");d.drawImage(a,0,0,o,l);let u=t;ha(d,o,l)||(u="image/jpeg");const h=await c.convertToBlob({type:u,quality:u==="image/jpeg"?ma:void 0}),p=h.type||u,m=await ga(h),y=Math.round(m.length*3/4/1024);return console.debug(`[image-resize] ${r}×${s} → ${o}×${l} | ${t} → ${p} | ${n} KB → ${y} KB`),{base64:m,mimeType:p}}async function fa(e,t){const n=atob(e),a=new Uint8Array(n.length);for(let s=0;s<n.length;s++)a[s]=n.charCodeAt(s);const r=new Blob([a],{type:t});return createImageBitmap(r)}function ha(e,t,n){const r=e.getImageData(0,0,t,n).data;for(let s=3;s<r.length;s+=4)if(r[s]<255)return!0;return!1}async function ga(e){const t=await e.arrayBuffer(),n=new Uint8Array(t);let a="";for(let r=0;r<n.length;r++)a+=String.fromCharCode(n[r]);return btoa(a)}const T={...Oe,badge:Oe.badgeRadius*2};function ya(e,t,n=1,a=0){const r=Math.max(1,e.displayScale)*n,s=[],i=o=>o*n;for(const{n:o,mark:l}of t){const c=l.geometry;if(c.kind==="rect")s.push({kind:"rect",x:i(c.x),y:i(c.y),w:i(c.w),h:i(c.h),width:T.stroke*r});else if(c.kind==="path")s.push({kind:"path",points:c.points.map(m=>({x:i(m.x),y:i(m.y)})),width:T.pen*r});else{const m={x:i(c.from.x),y:i(c.from.y)},y={x:i(c.to.x),y:i(c.to.y)};s.push({kind:"arrow",from:m,to:y,head:_a(m,y,T.arrowHead*r),width:T.stroke*r})}if(!T.showNumbers)continue;const d=Math.max(a,T.badge/2*r),u=i(l.bounds.x+l.bounds.w),h=i(l.bounds.y),p=Zt({x:i(l.bounds.x),y:h,w:u-i(l.bounds.x),h:i(l.bounds.h)},{x:0,y:0,w:i(e.width),h:i(e.height)},r,d);s.push({kind:"badge",...p,radius:d,label:String(o),font:d*T.badgeTextScale})}return s}function wa(e,t){"letterSpacing"in e&&(e.letterSpacing="0px"),"wordSpacing"in e&&(e.wordSpacing="0px");const n=(a,r,s)=>{e.strokeStyle=T.halo,e.lineWidth=a+T.haloWidth*r,s(),e.strokeStyle=T.accent,e.lineWidth=a,s()};e.strokeStyle=T.accent,e.lineCap="round",e.lineJoin="round";for(const a of t)if(a.kind==="rect")n(a.width,a.width/T.stroke,()=>e.strokeRect(a.x,a.y,a.w,a.h));else if(a.kind==="path"||a.kind==="arrow"){e.lineWidth=a.width,e.beginPath();const r=a.kind==="path"?a.points:[a.from,a.to];a.kind==="arrow"&&r.forEach((i,o)=>o?e.lineTo(i.x,i.y):e.moveTo(i.x,i.y)),a.kind==="arrow"&&(e.moveTo(a.head.left.x,a.head.left.y),e.lineTo(a.to.x,a.to.y),e.lineTo(a.head.right.x,a.head.right.y));const s=a.kind==="path"?new Path2D(Xt(a.points)):null;n(a.width,a.width/(a.kind==="path"?T.pen:T.stroke),()=>s?e.stroke(s):e.stroke())}else e.fillStyle=T.paper,e.beginPath(),e.arc(a.x,a.y,a.radius,0,Math.PI*2),e.closePath(),e.fill(),e.strokeStyle=T.accent,e.lineWidth=T.badgeOutline*a.radius/T.badgeRadius,e.stroke(),e.fillStyle=T.ink,e.font=`600 ${a.font}px ${T.badgeFontFamily}`,e.textAlign="center",e.textBaseline="middle",e.fillText(a.label,a.x,a.y)}async function ba(e,t){const n=Uint8Array.from(atob(e),a=>a.charCodeAt(0));return createImageBitmap(new Blob([n],{type:t}))}async function ka(e){const t=await e.convertToBlob({type:"image/png"});return Ze(await t.arrayBuffer())}async function ht(e,t,n,a,r=0){await nn();const s=await ba(e.base64,e.mimeType);try{const i=Math.min(1,a/Math.max(t.width,t.height)),o=new OffscreenCanvas(Math.max(1,Math.round(t.width*i)),Math.max(1,Math.round(t.height*i))),l=o.getContext("2d");if(!l)throw new Error("dock-evidence-canvas-unavailable");return l.drawImage(s,0,0,o.width,o.height),wa(l,ya(t,n,i,r)),o}finally{s.close()}}async function va(e,t,n){const a=await ht(e,t,n,Math.max(t.width,t.height));return pa(await ka(a),"image/png")}async function Gr(e,t,n,a=384){const r=await ht(e,t,n,a,a/32);return URL.createObjectURL(await r.convertToBlob({type:"image/png"}))}function _a(e,t,n=T.arrowHead){const a=Math.atan2(t.y-e.y,t.x-e.x),r=T.arrowSpread;return{left:{x:t.x-n*Math.cos(a-r),y:t.y-n*Math.sin(a-r)},right:{x:t.x-n*Math.cos(a+r),y:t.y-n*Math.sin(a+r)}}}function Jr(e,t){const n=zt(t??void 0),a=new Set(t?.clips.filter(r=>!!r.media&&!F(r.media)).map(r=>r.contextItemId));return e.filter(r=>!n.has(r.id)&&!a.has(r.id))}async function Yr({workspaceId:e,agentId:t,evidence:n,clickedItems:a,sendItems:r,clickedPayload:s,binding:i,service:o,current:l,onRecord:c,timing:d}){const u=()=>{if(!l()||!G(i))throw new O("validate","media-send-retired")};if(u(),n?.images.some(w=>w.mediaError)||n?.clips.some(w=>w.mediaError))throw new O("validate","invalid-saved-edit");const h=w=>!!w.media&&!F(w.media),p=n?{workspaceId:e,agentId:t,appUrl:`intent://local/workspace/${encodeURIComponent(e)}`,clipAttachmentIds:Object.fromEntries(n.clips.map(w=>[w.id,a.find(M=>M.id===w.contextItemId)?.attachmentId??null]))}:null;for(const w of n?.clips??[]){if(!w.media||!F(w.media))continue;const M=a.find(Q=>Q.id===w.contextItemId);if(!M||M.attachmentId!==w.media.source.attachmentId||M.path!==w.media.source.path||M.placementStatus!==void 0&&M.placementStatus!=="placed")throw new O("validate","legacy-original-unavailable")}const m=n?await ua(e,n,i,o,l,d):{images:{},files:[],frames:[],framePromptBytes:[],metadata:[]},y=new Set(n?.clips.filter(w=>h(w)||!!w.media&&F(w.media)).map(w=>w.id)),f=new Set(n?.clips.filter(w=>y.has(w.id)).flatMap(w=>(w.captureHistory??[]).map(M=>M.image.id))),k=(n?.images??[]).filter(w=>w.source!=="annotate"||!!w.media||!f.has(w.id)||n.marks.some(M=>M.imageId===w.id&&!(M.clipId&&y.has(M.clipId))));d?.stage("burn");let v=[];try{v=n?await Sa({...n,images:k},a,m.images):[]}catch(w){throw new O("burn",ie(w))}if(m.framePromptBytes.reduce((w,M)=>w+(M??0),0)>Hn)throw new O("validate","image-budget-exceeded");const S=new Set(n?.images.filter(w=>w.media).map(w=>w.id)),_=n?{...n,images:k.map(w=>m.images[w.id]?{...w,width:m.images[w.id].width,height:m.images[w.id].height}:w),clips:n.clips.filter(w=>!h(w)),marks:n.marks.filter(w=>!S.has(w.imageId)&&!n.clips.some(M=>h(M)&&M.id===w.clipId))}:null;u();const B=m.metadata.some(w=>typeof w.transcript=="string"&&w.transcript.trim());if(!s.text.trim()&&!r.length&&!s.workspaceContextStr?.trim()&&!v.length&&!m.files.length&&!m.frames.length&&!s.imageBlocks?.length&&!s.fileBlocks?.length&&!B)return null;let C=v,P=null;d?.stage("placement");const xe=n?await pt(i):null;if(u(),n&&(e!==be||xe?.chiefAttachments)){const w=await ca({workspaceId:e,binding:i,images:k.map((M,Q)=>{const X=a.find(Et=>Et.id===M.contextItemId);return{image:M,signature:Gt(n,M.id),composite:{base64:v[Q].data,mimeType:v[Q].mimeType},raw:!M.media&&X?.imageData&&X.imageMimeType?{base64:X.imageData,mimeType:X.imageMimeType}:null}}),records:n?.placements??{},onRecord:c});u(),C=w.map(M=>({type:"image",attachmentId:M.composite.attachmentId,mimeType:M.composite.mimeType})),P=Object.fromEntries(w.map(M=>[M.imageId,{attachmentId:M.composite.attachmentId,raw:M.raw}]))}const g=new Map(n?Xe(n).map(({n:w,mark:M})=>[M.id,w]):[]),D=p&&P?{...p,imageAttachments:P,markNumbers:g}:p&&{...p,markNumbers:g},L=n&&D?{...s,imageBlocks:[...C,...m.frames,...s.imageBlocks??[]],fileBlocks:[...s.fileBlocks??[],...m.files],workspaceContextStr:[Yt(_,D),m.metadata.length?`[Edited capture outputs]
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["/app/immutable/chunks/CoZeNthD.js","/app/immutable/chunks/Cz-HgbT1.js","/app/immutable/chunks/Bqd7fdCF.js","/app/immutable/chunks/CIyUrgF0.js","/app/immutable/chunks/51_h0jm2.js","/app/immutable/chunks/CJxGDkBm.js","/app/immutable/chunks/PXCFrn2V.js","/app/immutable/chunks/CpPNoOk-.js","/app/immutable/chunks/DxvSggY5.js","/app/immutable/assets/spinner.D_TRo5Hy.css","/app/immutable/chunks/BnA9v3pc.js","/app/immutable/chunks/NtFyWdpR.js","/app/immutable/chunks/Bjy4ygfJ.js","/app/immutable/chunks/rIUowGAi.js","/app/immutable/chunks/BQDGTBxC.js","/app/immutable/chunks/uXuxG9cN.js","/app/immutable/assets/button.-yaUNjRS.css","/app/immutable/chunks/DGmOjLYi.js","/app/immutable/chunks/C9UsZ4re.js","/app/immutable/chunks/DqFWZ_g1.js","/app/immutable/chunks/BLb6jd9K.js","/app/immutable/chunks/CI4_aI7e.js","/app/immutable/chunks/PVXvIyE8.js","/app/immutable/chunks/ChTqQfQN.js","/app/immutable/chunks/BEklUrxK.js","/app/immutable/chunks/DxwfiAWm.js","/app/immutable/chunks/DJfJ5NWH.js","/app/immutable/chunks/DSQT151l.js","/app/immutable/chunks/BxwkoIbZ.js","/app/immutable/chunks/BoIfXiRv.js","/app/immutable/chunks/XJv96NUg.js","/app/immutable/assets/notify.B1j5oT2y.css","/app/immutable/chunks/C2wWLl1x.js","/app/immutable/chunks/DypB-Dwi.js","/app/immutable/chunks/BoQ8Q7zJ.js","/app/immutable/chunks/CL3a4Hm1.js","/app/immutable/chunks/BBWuirRW.js","/app/immutable/chunks/BdWqymET.js","/app/immutable/chunks/BOWO4Ybr.js","/app/immutable/chunks/DKwAaLwd.js","/app/immutable/chunks/CAV1CzzW.js","/app/immutable/chunks/Dq9sK6wY.js","/app/immutable/chunks/BHCTYYXY.js","/app/immutable/chunks/DQLMO9xD.js","/app/immutable/chunks/DQZlstPH.js","/app/immutable/chunks/B5aYN90J.js","/app/immutable/chunks/Dnz4szur.js","/app/immutable/chunks/CMiilI_P.js","/app/immutable/chunks/DWDPOFkL.js","/app/immutable/chunks/DaqXt9wp.js","/app/immutable/chunks/DONrLvvt.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Ct=Object.defineProperty;var Dt=(e,t,n)=>t in e?Ct(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Pe=(e,t,n)=>Dt(e,typeof t!="symbol"?t+"":t,n);import{J5 as A,i as be,nM as R,wc as Rt,C9 as Ge,we as xt,Dm as Je,cE as Pt,cF as Bt,nN as Ye,nz as Ot,e as ke,fM as $t,l_ as Ut,cM as Lt}from"./CI4_aI7e.js";import{J as Nt,Z as Ht,dT as Be,cR as pe,dE as Ft,aw as Kt,bc as Qe,I as Wt,e4 as jt}from"./C2wWLl1x.js";import{e as qt,b as ae,F as Vt,y as re,_ as ve,G as zt,C as Gt,W as Xe,v as Jt,u as Yt,M as Qt}from"./BEklUrxK.js";import{D as Oe,a as Xt,d as Zt}from"./CQcEqK4G.js";import{m as en,g as Ze,r as tn,k as nn,D as an}from"./1q0xL14K.js";import{e as rn}from"./CL3a4Hm1.js";import{z as et,O as sn}from"./Bqd7fdCF.js";import{a as on}from"./Dz5-AChV.js";import{f as cn}from"./CQkTODWA.js";import{bm as b,_ as fe}from"./51_h0jm2.js";import{aa as tt,aB as se,J as he,a as nt,n as at,cS as rt,e as st,aI as it,M as ln,ac as dn,aV as $e,d as le,C as un,cT as mn,U as pn,a6 as fn,aJ as hn,b_ as gn}from"./CmdzVgvT.js";import{W as yn,L as wn,w as bn,R as kn,M as vn,h as _n}from"./rIUowGAi.js";import{l as q,i as Sn,n as Mn}from"./DqFWZ_g1.js";import{x as An,J as In,ai as Tn,ar as En}from"./Cov6EESF.js";import{a as Ue,b as Cn,g as Dn}from"./DypB-Dwi.js";import{m as Rn}from"./CAV1CzzW.js";import{C as xn}from"./B5aYN90J.js";import{i as Pn}from"./BZWU4mlm.js";import{o as $,e as Bn,l as V,s as E,n as ce,b as On,d as $n,c as Un}from"./CIyUrgF0.js";const Rr=A.createSelector((e,t)=>e.unreadTracking.dividerSessionByAgentId[t]??null),xr=A.createSelector(e=>e.unreadTracking.currentlyViewedAgentId),Pr=A.createSelector(e=>{const t=[];for(const s of Object.values(e.panelLayout.byWorkspaceId))for(const i of Object.values(s.panels))for(const o of i.tabs)o.type==="agent"&&o.agentId&&t.push(o.agentId);const n=Object.keys(e.unreadTracking.dividerSessionByAgentId),a=new Set(e.agentSessions.agentIdsByWorkspace[be]??[]);return{chiefCardVisible:e.sidebarNav.panelItem==="chief",chiefSessionAgentIds:n.filter(s=>a.has(s)),dividerSessionAgentIds:n,openAgentTabIds:t}});function Br(e,t){if(e)return e.model}function Ln({messages:e,pendingInitialPrompt:t,pendingContextReferenceCount:n=0}){return e.length>0||!!t||n>0}function Or({session:e,messages:t,pendingInitialPrompt:n,pendingContextReferenceCount:a=0}){return!(e?Nt(e):!1)&&!Ln({messages:t,pendingInitialPrompt:n,pendingContextReferenceCount:a})}function $r(e){return Ht(e.messageMetadata)}function Nn(e){return{id:e.id,appMessageId:e.appMessageId,role:"user",timestamp:new Date(e.createdAt??0).toISOString(),contentBlocks:[...e.content?[{type:"text",text:e.content}]:[],...e.imageBlocks??[],...e.fileBlocks??[]],metadata:e.messageMetadata,...e.author!==void 0?{author:e.author}:{}}}function Ur(e){return Nn({...e,createdAt:Date.parse(e.queuedAt)})}const Hn=8*1024*1024,Fn=3*1024*1024;function Kn(e){return Math.ceil(Math.max(0,e)/3)*4}function Wn(e){const t=e.promptBase64Bytes;return e.mimeType==="image/jpeg"&&Number.isSafeInteger(e.size)&&e.size>0&&e.size<=Fn&&typeof t=="number"&&t===Kn(e.size)?t:null}async function ot(e,t,n,a,r=()=>{}){const s=()=>{if(!a())throw new Error("media-send-retired")};if(s(),r("overlay-render"),!n.exportMedia)throw new Error("media-export-unavailable");const i=on(e.source,e.saved);if(i.length>1e4)throw new Error("media-animation-layer-limit");const o=[];for(const c of i)s(),o.push({...c,png:await en(e.source,e.saved,c.atMs)});s(),r("export");const l=await n.exportMedia({outputVersion:qt,jobId:t,media:e,layers:o});if(s(),!l.ok)throw new Error(["media-export-failed",l.error].filter(Boolean).join(":"));return{jobId:t,value:l.value}}const _e={CLIPBOARD_WRITE:"dock-media:clipboard-write",CLIPBOARD_READ:"dock-media:clipboard-read",MENU:"dock-media:menu"};function Le(e,t){return Math.max(0,(e.pausedAt??t)-e.startedAt-(e.pausedMs??0))}function ge(e,t){if(!t?.startsWith(".intent/attachments/"))return;const n=t.split("/").map(encodeURIComponent).join("/"),a=tt(`intent://local/file/${n}`,e);return a?.kind==="video"?a.url:void 0}function jn(e){const t=e.video==="full"?b.dock_captureEditor_videoFull_label():b.dock_captureEditor_videoHighlights_label(),n=e.voice==="audio"?b.dock_captureEditor_voiceAudio_label():e.voice==="transcript"?b.dock_captureEditor_voiceTranscript_label():b.dock_captureEditor_voiceOff_summary();return`${t} · ${n}`}function qn(e,t,n,a){if(a?.error==="permission")return a.kind==="pick"?"accessibility":"screen";if(e==="permission"||t==="permission")return"screen";if(n?.startsWith("microphone-permission"))return"microphone";if(n?.startsWith("speech-permission"))return"speech"}const j=cn;function Lr(e){const{view:t,items:n,local:a,labels:r,copy:s}=e,i=t.speech.error??t.speech.capability?.reason??null,o=qn(t.captureError,t.clips.find(g=>g.status==="failed"&&g.error==="permission")?.error??null,i,t.annotationIssue),l=t.annotationIssue?.error==="unavailable"?s?.annotationUnavailable:void 0,c=t.annotationIssue,d=t.captureError==="permission",u=c?.error==="permission"&&c.kind!=="pick",h=c?.error==="permission"&&c.kind==="pick",p=i?.startsWith("speech-permission")?"speech":i?.startsWith("microphone-permission")||i==="permission"?"microphone":void 0,m={},y={},f=(g,D,L)=>{m[g]=D,L&&(y[g]=L)};s&&(d&&(f("capture",s.permission,"screen"),t.recording||f("record",s.permission,"screen")),u&&!t.annotating&&f("annotate",s.permission,"screen"),h&&(f("pick",s.accessibilityPermission,"accessibility"),t.tool==="pick"&&!t.annotating&&f("annotate",s.accessibilityPermission,"accessibility")),p&&!t.dictation&&f("mic",(i&&r.speechError?.(i))??s.speechPermission,p));const k=g=>{const D=y[g];D&&e.actions.onOpenSettings(D)},v=new Set(t.evidenceOwnedItemIds),I=t.clips.find(g=>g.status==="recording"),S=t.clips.length>=ae.clips,_=t.capabilities,B=t.speech.available,C=new Set(t.clips.filter(g=>g.status==="recording"||g.status==="placing"||!!g.media).flatMap(g=>g.captureHistory?.map(D=>D.image.id)??[])),P=[...t.tiles.filter(({image:g,marks:D})=>!!g.media||g.source!=="annotate"||!C.has(g.id)||D.some(({mark:L})=>!L.clipId)).map(({image:g,marks:D})=>({kind:"image",id:g.contextItemId,url:a.previews[g.id]??"",markCount:D.length,owner:"evidence",...a.previews[g.id]?{}:{status:"placing"}})),...t.clips.filter(g=>!g.discarding).map(g=>({kind:"clip",id:g.contextItemId??g.id,duration:j(g.status==="recording"?Le(g,a.now):g.durationMs),recording:g.status==="recording",...g.media?.saved?{summary:jn(g.media.saved)}:{},...g.status==="ready"&&ge(e.workspaceId,g.path)?{url:ge(e.workspaceId,g.path)}:{},owner:"evidence",...g.status==="placing"?{status:"placing"}:{},...g.status==="failed"?{status:"failed",...g.error==="limit"?{error:b.dock_composer_clipTooLarge_error()}:{}}:{}})),...n.filter(g=>!v.has(g.id)).map(g=>({...g.imageData&&g.imageMimeType?{kind:"image",id:g.id,url:`data:${g.imageMimeType};base64,${g.imageData}`,markCount:0,file:{name:g.label,imageData:g.imageData,imageMimeType:g.imageMimeType}}:{kind:"file",id:g.id,name:g.label},owner:"attachment",...g.placementStatus==="placing"?{status:"placing"}:{},...g.placementStatus==="failed"?{status:"failed",error:g.placementError}:{}}))];return{mediaStatus:t.recording?{kind:"recording",label:r.recording}:t.annotating?{kind:"annotating",label:r.annotating}:void 0,...o?{settingsPane:o}:{},...l?{annotationNotice:l}:{},labels:r,attachments:P,...s?{placeholder:t.dictation?"":s.idle}:{},state:{captureRevision:t.captureAccepted,capturePending:t.capturePending,captureDisabled:!_.capture||t.captureDisabled,...t.captureDisabled?{captureTooltip:r.captureLimit}:{},captureMode:t.evidence?.annotation?"fullscreen":t.captureMode,captureModesAvailable:!!_.captureModes&&!t.evidence?.annotation,annotationActive:t.annotating,tool:t.tool,toolUsed:t.toolUsed,annotationDisabled:!_.annotate,recording:t.recording&&!I?.discarding,recordingDisabled:!!I?.discarding||!t.recording&&(!_.record||S),...S&&!t.recording?{recordingTooltip:r.clipLimit}:{},recordingTime:j(I?Le(I,a.now):0),dictating:!!t.dictation,dictationPending:t.speech.pending||t.dictation?.status==="transcribing",dictationDisabled:!B&&!t.dictation&&!m.mic,...t.speech.error&&r.speechError?{dictationTooltip:r.speechError(t.speech.error)}:{},dictationTime:t.dictation?j(a.now-t.dictation.startedAt):j(0),inputLevels:t.speech.levels,...Object.keys(m).length?{alerts:m}:{}},...e.actions,...t.fileAttachmentsEnabled===!1?{onEdit:void 0}:{},onAlert:k,beforeSubmit:e.beforeSubmit}}const Se=()=>globalThis.electronAPI,Vn=["image/png","image/jpeg","image/webp"],Ne=e=>Vn.includes(e??"")?e:null;function He(e){const t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;a+=1)n[a]=t.charCodeAt(a);return n}async function Nr(e,t){const{view:n,items:a,previews:r}=t,s=n.tiles.find(({image:c})=>c.id===e||c.contextItemId===e);if(s){const c=a.find(p=>p.id===s.image.contextItemId),d=s.image.media;if(s.image.mediaError)return null;if(d?.saved){if(!t.createSavedPreviewUrl||!t.revokeUrl)return null;const p={...d,saved:d.saved},m=await t.createSavedPreviewUrl(t.workspaceId,p);try{const y=await t.fetchBytes(m),f=p.saved.crop;return{kind:"image",name:c?.label||"screenshot.png",mimeType:"image/png",bytes:y,intent:{pixels:{mimeType:"image/png",width:Math.max(1,Math.round(f?.w??p.source.width)),height:Math.max(1,Math.round(f?.h??p.source.height)),displayScale:s.image.displayScale,capturedAt:s.image.capturedAt},raw:y,marks:[]}}}finally{t.revokeUrl(m)}}const u=Ne(c?.imageMimeType),h=r[s.image.id];return!c?.imageData||!u||!h?null:{kind:"image",name:c.label||"screenshot.png",mimeType:"image/png",bytes:await t.fetchBytes(h),intent:{pixels:{mimeType:u,width:s.image.width,height:s.image.height,displayScale:s.image.displayScale,capturedAt:s.image.capturedAt,...s.image.hash?{hash:s.image.hash}:{}},raw:He(c.imageData),marks:s.marks.map(({mark:p})=>({tool:p.tool,geometry:p.geometry,bounds:p.bounds,element:p.element}))}}}const i=n.clips.find(c=>c.id===e||c.contextItemId===e);if(i){const c=i.status==="ready"?ge(t.workspaceId,i.path):null;if(!c)return null;const d=a.find(h=>h.id===i.contextItemId),u=await t.fetchBytes(c);if(!Gn(u))throw new Error("Not a recording file");return{kind:"clip",name:d?.label||`recording-${i.id.slice(0,8)}.mp4`,mimeType:d?.attachmentMimeType||"video/mp4",bytes:u,durationMs:i.durationMs,hasMicAudio:i.hasMicAudio}}const o=a.find(c=>c.id===e),l=Ne(o?.imageMimeType);return o?.imageData&&l?{kind:"image",name:o.label||"image",mimeType:l,bytes:He(o.imageData)}:null}async function zn(e){const t=await fetch(e);if(!t.ok)throw new Error(`Media request failed (${t.status})`);const n=new Uint8Array(await t.arrayBuffer()),a=Number(t.headers.get("content-length")??Number.NaN);if(n.byteLength===0||Number.isFinite(a)&&a!==n.byteLength)throw new Error("Media response was incomplete");return n}function Gn(e){return e.byteLength>8&&String.fromCharCode(...e.subarray(4,8))==="ftyp"}async function Hr(e){try{return(await Se()?.invoke(_e.CLIPBOARD_WRITE,e))?.ok===!0}catch{return!1}}async function Jn(){try{return await Se()?.invoke(_e.CLIPBOARD_READ,{})??null}catch{return null}}async function Fr(e){try{const t=await Se()?.invoke(_e.MENU,{canCut:e});return t?.action==="copy"||t?.action==="cut"?t.action:null}catch{return null}}const Fe=new WeakSet;async function Yn(e,t){const[n]=e;if(e.length!==1||!n||n.size!==t.size)return!1;try{const a=await crypto.subtle.digest("SHA-256",await n.arrayBuffer());return Array.from(new Uint8Array(a),s=>s.toString(16).padStart(2,"0")).join("")===t.sha256}catch{return!1}}function Kr(e,{onIntentMedia:t,isCurrent:n,read:a=Jn}){const r=e.clipboardData;if(Fe.has(e)||!r||r.files.length===0)return!1;const s=e.target,i=Array.from(r.files),o=r.types.filter(l=>l!=="Files").map(l=>[l,r.getData(l)]);return e.preventDefault(),e.stopImmediatePropagation(),a().catch(()=>null).then(async l=>{if(!n())return;if(l&&await Yn(i,l)){n()&&t(l);return}if(!n()||!(s instanceof Node)||!s.isConnected)return;const c=new DataTransfer;for(const u of i)c.items.add(u);for(const[u,h]of o)c.setData(u,h);const d=new ClipboardEvent("paste",{clipboardData:c,bubbles:!0,cancelable:!0});Fe.add(d),s.dispatchEvent(d)}),!0}function Qn(e){const t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;a++)n[a]=t.charCodeAt(a);return n}function Xn(e){let t="";for(let a=0;a<e.length;a+=32768)t+=String.fromCharCode(...e.subarray(a,a+32768));return btoa(t)}function ct(e){let t=0;return e.endsWith("==")?t=2:e.endsWith("=")&&(t=1),Math.floor(e.length*3/4)-t}async function Zn(e){const t=await crypto.subtle.digest("SHA-256",e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength));return Array.from(new Uint8Array(t)).map(n=>n.toString(16).padStart(2,"0")).join("")}const lt={placeAttachment:it,beginAttachmentUpload:st,sendAttachmentUploadChunk:rt,commitAttachmentUpload:at,abortAttachmentUpload:nt,getAttachmentInfo:he,mintIdempotencyKey:se};async function Me(e,t,n,a=lt){const{idempotencyKey:r}=n,s={...r!==void 0?{idempotencyKey:r}:{},...n.rawScreenshot!==void 0?{rawScreenshot:n.rawScreenshot}:{}},i=async m=>mn(m,r)?$e(e,r,a.getAttachmentInfo):void 0;if(ct(n.data)<=ln)try{return await a.placeAttachment(e,t,{data:n.data,mimeType:n.mimeType,...s})}catch(m){const y=await i(m);if(y)return y;throw m}const o=Qn(n.data),l=await Zn(o);let c,d;try{({uploadId:c,maxChunkBytes:d}=await a.beginAttachmentUpload(e,t,o.byteLength,l,{mimeType:n.mimeType,...s}))}catch(m){if(r!==void 0&&dn(m)){const y=await $e(e,r,a.getAttachmentInfo);if(y)return y}throw m}const u=Math.min(pn,d),h=Math.ceil(o.byteLength/u);let p=!1;try{for(let m=0;m<h;m++){const y=o.subarray(m*u,(m+1)*u);await a.sendAttachmentUploadChunk(c,m,Xn(y),e)}return p=!0,await a.commitAttachmentUpload(c,e)}catch(m){const y=p?await i(m):void 0;if(y)return y;throw await a.abortAttachmentUpload(c,e).catch(()=>{}),m}}function ea(e,t){return fn(e,`image-${Date.now()}-${t+1}`)}class Ae extends Error{constructor(n,a){super(n);Pe(this,"retryBlocks");this.name="ImagePlacementError",this.retryBlocks=a}}function ta(e,t){return e instanceof Ae?e.retryBlocks:t}async function na(e,t,n=lt,a=()=>!0){const r=l=>(...c)=>(le(a),l(...c));n={placeAttachment:r(n.placeAttachment),beginAttachmentUpload:r(n.beginAttachmentUpload),sendAttachmentUploadChunk:r(n.sendAttachmentUploadChunk),commitAttachmentUpload:r(n.commitAttachmentUpload),abortAttachmentUpload:r(n.abortAttachmentUpload),getAttachmentInfo:r(n.getAttachmentInfo),mintIdempotencyKey:r(n.mintIdempotencyKey)};const s=[],i=[],o=[];for(let l=0;l<t.length;l++){le(a);const c=t[l];if("attachmentId"in c&&c.attachmentId){const p={type:"image",attachmentId:c.attachmentId,...c.mimeType?{mimeType:c.mimeType}:{}};s.push(p),i.push(p);continue}const d=c,u=d.placementFileName??ea(d.mimeType,l),h=n.mintIdempotencyKey(d.placementIdempotencyKey);try{const p=await Me(e,u,{data:d.data,mimeType:d.mimeType,...h!==void 0?{idempotencyKey:h}:{}},n),m={type:"image",attachmentId:p.attachmentId,...p.mimeType??d.mimeType?{mimeType:p.mimeType??d.mimeType}:{}};s.push(m),i.push(m)}catch(p){const m=un(p);o.push(m?`${u} (${m})`:u),i.push(h!==void 0?{...d,placementIdempotencyKey:h,placementFileName:u}:d)}}if(o.length>0)throw new Ae(b.chat_imagePlacement_failed_error({names:o.join(", ")}),i);return le(a),s}const Wr=Object.freeze(Object.defineProperty({__proto__:null,ImagePlacementError:Ae,base64DecodedBytes:ct,imageRetryBlocks:ta,placeImageAttachment:Me,toImageReferenceBlocks:na},Symbol.toStringTag,{value:"Module"}));function dt(){try{return yn()}catch{return null}}function aa(){return{backendId:A.state.connections.windowBackendId??null,generation:A.state.daemonHealth.connectionGeneration,transport:dt()}}class Ie extends Error{constructor(){super("dock-evidence-backend-changed")}}function N(e,t){return async(...n)=>{e();const a=await t(...n);return e(),a}}const H={current:e=>dt()===e.transport&&A.state.daemonHealth.connectionGeneration===e.generation&&(A.state.connections.windowBackendId??null)===e.backendId,capabilities:()=>wn(),placeImage:(e,t,n,a)=>Me(e,t,n,{placeAttachment:N(a,it),beginAttachmentUpload:N(a,st),sendAttachmentUploadChunk:N(a,rt),commitAttachmentUpload:N(a,at),abortAttachmentUpload:N(a,nt),getAttachmentInfo:N(a,he),mintIdempotencyKey:se}),lookup:(e,t)=>he({workspaceId:e,idempotencyKey:t}),mintKey:se};function G(e){return H.current(e)}function ra(e,t){const n=A.state.dockConversation;return{generation:n.generation,authority:n.authority,clearRevision:R(n.drafts,Vt(e,t))?.clearRevision??0,binding:aa()}}function jr(e,t,n){const a=ra(e,t);return a.generation===n.generation&&a.authority===n.authority&&a.clearRevision===n.clearRevision&&G(n.binding)}function ut(e,t){return()=>{if(!e.current(t))throw new Ie}}const mt=Object.freeze({rawRetention:!1,chiefAttachments:!1});function qr(e){return e!==mt}const de=new Map;function pt(e,t=H){const n=`${e.backendId}:${e.generation}`;let a=de.get(n);if(!a){const r=ut(t,e);a=(async()=>{r();const i=await t.capabilities();r();const o=i?.server?.capabilities;if(!o||typeof o!="object")throw new Error("unobserved");return{rawRetention:o.rawScreenshotRetention===1,chiefAttachments:o.chiefAttachments===1}})().catch(()=>(de.delete(n),mt)),de.set(n,a)}return a}class Z extends Error{constructor(t){super(`dock-raw-retention-contract:${t}`),this.reason=t}}function ft(e){const{rpcCode:t,code:n}=e??{};return t===-32602||n==="INVALID_PARAMS"}function sa(e){const t=String(e?.message??"");return ft(e)&&(t.includes("rawScreenshotExpired:")||/expired at .*not renewable/i.test(t))}function ia(e,t,n){const a=e.rawScreenshot;if(!a||a.compositeAttachmentId!==t)return null;const r=Date.parse(a.expiresAt);return Number.isFinite(r)?a.expired||r<=n?"expired":{attachmentId:e.attachmentId,expiresAt:a.expiresAt}:null}function Ke(e){return{ok:!0,path:e.path,fileName:e.fileName,size:e.size,attachmentId:e.attachmentId,...e.mimeType?{mimeType:e.mimeType}:{},uploadedAt:e.uploadedAt,replayed:!0,...e.rawScreenshot?{rawScreenshot:e.rawScreenshot}:{}}}class oa extends Error{constructor(t,n){super("dock-evidence-placement-failed"),this.imageId=t,this.failure=n}}const We=e=>e.split("/")[1]?.replace("jpeg","jpg")||"png";async function ca(e){const t=e.api??H,n=e.now??Date.now,a=ut(t,e.binding);a();const r=await pt(e.binding,t);a();const s=r.rawRetention&&(e.workspaceId!==be||r.chiefAttachments),i=[];for(const o of e.images){const l=e.records[o.image.id];let c=l&&l.signature===o.signature&&l.workspaceId===e.workspaceId&&l.backendId===e.binding.backendId?l:{imageId:o.image.id,signature:o.signature,workspaceId:e.workspaceId,backendId:e.binding.backendId,compositeKey:null,rawKey:null,composite:null,raw:null,rawSettled:!1};const d=u=>{c=u,e.onRecord(u)};try{if(!c.composite){const h=c.compositeKey,p=t.mintKey(h??void 0)??null;p!==c.compositeKey&&d({...c,compositeKey:p});let m;h&&p===h&&(a(),m=await t.lookup(e.workspaceId,p).then(Ke).catch(()=>{}),a()),m||(a(),m=await t.placeImage(e.workspaceId,`screenshot-${o.image.id.slice(0,8)}.${We(o.composite.mimeType)}`,{data:o.composite.base64,mimeType:o.composite.mimeType,...p?{idempotencyKey:p}:{}},a),a()),d({...c,composite:{attachmentId:m.attachmentId,mimeType:m.mimeType??o.composite.mimeType}})}const u=c.composite.attachmentId;if(s&&o.raw&&!c.raw&&!c.rawSettled){const h=c.rawKey,p=t.mintKey(h??void 0);if(p){p!==c.rawKey&&d({...c,rawKey:p});let m;h&&p===h&&(a(),m=await t.lookup(e.workspaceId,p).then(Ke).catch(()=>{}),a());try{m||(a(),m=await t.placeImage(e.workspaceId,`screenshot-${o.image.id.slice(0,8)}-original.${We(o.raw.mimeType)}`,{data:o.raw.base64,mimeType:o.raw.mimeType,idempotencyKey:p,rawScreenshot:{compositeAttachmentId:u}},a),a());const y=ia(m,u,n());if(y==="expired")d({...c,rawSettled:!0});else if(y)d({...c,raw:y});else throw new Z("echo")}catch(y){if(sa(y))d({...c,rawSettled:!0});else throw y instanceof Z?y:ft(y)?new Z("refused"):y}}else throw new Z("unkeyed")}}catch(u){throw u instanceof Ie?u:new oa(o.image.id,u)}i.push(c)}return i}async function Vr(e,t,n,a){const r=()=>{if(!H.current(a))throw new Ie};r();const s=await H.placeImage(e,t,{...n,idempotencyKey:H.mintKey()},r);return r(),s}const la=new Set(["invalid-saved-edit","media-send-retired","transcript-unavailable","transcript-pending","invalid-edit","stale-source","legacy-baked-marks","timing-unavailable","audio-unavailable","media-source-unavailable","media-export-unavailable","media-animation-layer-limit","media-export-failed","legacy-original-unavailable","capture-render-unavailable","capture-blur-unavailable","stale-source-pixels","not-a-screenshot","not-admitted","unavailable","dock-evidence-missing-pixels","draft-restore-failed","image-budget-exceeded"]),da=new Set(["unavailable","permission","failed","busy","cancelled","limit"]);class O extends Error{constructor(t,n){super(n),this.stage=t,this.code=n,this.name="DockSendError"}}function ie(e){const t=e instanceof Error?e.message:typeof e=="string"?e:"";if(t.length>64)return"unclassified";const[n,...a]=t.split(":");return!la.has(n)||a.length>2?"unclassified":n!=="media-export-failed"?a.length?"unclassified":n:[n,...a.map(r=>da.has(r)?r:"other")].join(":")}function zr(e,t){return e instanceof O?{stage:e.stage,code:ie(e.code)}:{stage:t,code:ie(e)}}function F(e){if(!e||e.source.kind!=="recording")return!1;const t=e.source,n=e.saved??re(t,t.capturedMarks??[],e.transcript);if(n.video!=="full"||n.voice!=="audio"||n.crop||n.blurRegions.length||n.blurStrokes?.length)return!1;const a=ve(n,t,e.transcript);return t.visuals==="clean"?!a.errors.length&&!a.muted&&n.cuts.length===0&&!n.marks.some(r=>r.included)&&a.marks.length===0&&a.transcript===null&&a.kept.length===1&&a.kept[0].startMs===0&&a.kept[0].endMs===t.durationMs&&a.clips.length===1&&a.clips[0].startMs===0&&a.clips[0].endMs===t.durationMs:!a.errors.length&&!a.muted&&a.clips.length===1&&a.clips[0].startMs===0&&a.clips[0].endMs>=t.durationMs}async function ua(e,t,n,a,r,s){const i={images:{},files:[],frames:[],framePromptBytes:[],metadata:[]};let o="validate";try{const l=()=>{if(!r()||!G(n))throw new Error("media-send-retired")};for(const c of[...t.images,...t.clips]){if(o="validate",s?.stage(o),c.mediaError)throw new Error("invalid-saved-edit");if(!c.media||F(c.media))continue;l();const d=structuredClone(c.media),u=d.source;let h=d.saved??re(u,u.capturedMarks??[],d.transcript),p=crypto.randomUUID();try{if(u.kind==="recording"&&h.voice==="transcript"&&d.transcript?.status!=="ready"){if(o="transcribe",s?.stage(o),!a?.transcribeMedia)throw new Error("transcript-unavailable");const f=await a.transcribeMedia({jobId:p,media:d});if(l(),!f.ok)throw new Error("transcript-unavailable");d.transcript=f.value,d.saved||(h=re(u,u.capturedMarks??[],d.transcript))}o="plan",s?.stage(o);const m=ve(h,u,d.transcript);if(m.errors.length)throw new Error(m.errors[0]);const y={id:c.id,kind:u.kind,video:h.video,voice:h.voice,transcript:m.transcript,batches:u.batches,marks:m.marks.map(({n:f,mark:k,frameAtMs:v})=>({n:f,id:k.id,at_ms:v,kind:k.kind,label:k.label,note:k.note,context:k.context,geometry:k.geometry}))};if(u.kind==="screenshot"){o="screenshot-source",s?.stage(o);const f=u.path.split("/").map(encodeURIComponent).join("/"),k=tt(`intent://local/file/${f}`,e);if(!k||k.kind!=="image")throw new Error("media-source-unavailable");const v=await zn(k.url);l();const I={base64:Ze(v.buffer.slice(v.byteOffset,v.byteOffset+v.byteLength)),mimeType:/\.jpe?g$/i.test(u.path)?"image/jpeg":/\.webp$/i.test(u.path)?"image/webp":"image/png"};o="screenshot-render",s?.stage(o),i.images[c.id]=await tn(u,h,I),l()}else{if(!m.clips.length){y.video_attachment_id=null,y.frames=[],y.kept_ms=[],i.metadata.push(y);continue}const f={...d,saved:h};let k=await a?.takePreparedRecording?.(f);if(k&&(p=k.jobId),l(),!k){if(!a)throw new Error("media-export-unavailable");k=await ot(f,p,a,()=>r()&&G(n),S=>{o=S,s?.stage(S),S==="export"&&s?.exportAttempt(p)})}p=k.jobId,o="placement",s?.stage(o);const v=[k.value.video,...k.value.frames],I=[];for(let S=0;S<v.length;S++){l();const _=v[S],B=`capture-${c.id.slice(0,12)}-${S}.${S===0?"mp4":_.mimeType==="image/jpeg"?"jpg":"png"}`,C=await hn(e,B,{sourcePath:_.sourcePath,mimeType:_.mimeType,idempotencyKey:se()},void 0,void 0,()=>r()&&G(n));l(),S===0?i.files.push({type:"file",attachmentId:C.attachmentId,fileName:B,mimeType:C.mimeType??_.mimeType,size:C.size}):(i.frames.push({type:"image",attachmentId:C.attachmentId,mimeType:_.mimeType==="image/jpeg"?"image/jpeg":"image/png"}),i.framePromptBytes.push(Wn(_))),I.push(C.attachmentId)}y.video_attachment_id=I[0],y.frames=k.value.frames.map((S,_)=>({mark_id:S.markId,attachment_id:I[_+1]})),y.kept_ms=m.clips}i.metadata.push(y)}finally{s?.stage("release"),await a?.releaseMediaJob?.(p).catch(()=>{})}}return i}catch(l){throw l instanceof O?l:new O(o,ie(l))}}const ue=1568,ma=.85;async function pa(e,t){const n=Math.round(e.length*3/4/1024),a=await fa(e,t),{width:r,height:s}=a,i=r>ue||s>ue;let o=r,l=s;if(i){const f=ue/Math.max(r,s);o=Math.round(r*f),l=Math.round(s*f)}const c=new OffscreenCanvas(o,l),d=c.getContext("2d");if(!d)throw new Error("Failed to get 2D canvas context for image resize");d.drawImage(a,0,0,o,l);let u=t;ha(d,o,l)||(u="image/jpeg");const h=await c.convertToBlob({type:u,quality:u==="image/jpeg"?ma:void 0}),p=h.type||u,m=await ga(h),y=Math.round(m.length*3/4/1024);return console.debug(`[image-resize] ${r}×${s} → ${o}×${l} | ${t} → ${p} | ${n} KB → ${y} KB`),{base64:m,mimeType:p}}async function fa(e,t){const n=atob(e),a=new Uint8Array(n.length);for(let s=0;s<n.length;s++)a[s]=n.charCodeAt(s);const r=new Blob([a],{type:t});return createImageBitmap(r)}function ha(e,t,n){const r=e.getImageData(0,0,t,n).data;for(let s=3;s<r.length;s+=4)if(r[s]<255)return!0;return!1}async function ga(e){const t=await e.arrayBuffer(),n=new Uint8Array(t);let a="";for(let r=0;r<n.length;r++)a+=String.fromCharCode(n[r]);return btoa(a)}const T={...Oe,badge:Oe.badgeRadius*2};function ya(e,t,n=1,a=0){const r=Math.max(1,e.displayScale)*n,s=[],i=o=>o*n;for(const{n:o,mark:l}of t){const c=l.geometry;if(c.kind==="rect")s.push({kind:"rect",x:i(c.x),y:i(c.y),w:i(c.w),h:i(c.h),width:T.stroke*r});else if(c.kind==="path")s.push({kind:"path",points:c.points.map(m=>({x:i(m.x),y:i(m.y)})),width:T.pen*r});else{const m={x:i(c.from.x),y:i(c.from.y)},y={x:i(c.to.x),y:i(c.to.y)};s.push({kind:"arrow",from:m,to:y,head:_a(m,y,T.arrowHead*r),width:T.stroke*r})}if(!T.showNumbers)continue;const d=Math.max(a,T.badge/2*r),u=i(l.bounds.x+l.bounds.w),h=i(l.bounds.y),p=Zt({x:i(l.bounds.x),y:h,w:u-i(l.bounds.x),h:i(l.bounds.h)},{x:0,y:0,w:i(e.width),h:i(e.height)},r,d);s.push({kind:"badge",...p,radius:d,label:String(o),font:d*T.badgeTextScale})}return s}function wa(e,t){"letterSpacing"in e&&(e.letterSpacing="0px"),"wordSpacing"in e&&(e.wordSpacing="0px");const n=(a,r,s)=>{e.strokeStyle=T.halo,e.lineWidth=a+T.haloWidth*r,s(),e.strokeStyle=T.accent,e.lineWidth=a,s()};e.strokeStyle=T.accent,e.lineCap="round",e.lineJoin="round";for(const a of t)if(a.kind==="rect")n(a.width,a.width/T.stroke,()=>e.strokeRect(a.x,a.y,a.w,a.h));else if(a.kind==="path"||a.kind==="arrow"){e.lineWidth=a.width,e.beginPath();const r=a.kind==="path"?a.points:[a.from,a.to];a.kind==="arrow"&&r.forEach((i,o)=>o?e.lineTo(i.x,i.y):e.moveTo(i.x,i.y)),a.kind==="arrow"&&(e.moveTo(a.head.left.x,a.head.left.y),e.lineTo(a.to.x,a.to.y),e.lineTo(a.head.right.x,a.head.right.y));const s=a.kind==="path"?new Path2D(Xt(a.points)):null;n(a.width,a.width/(a.kind==="path"?T.pen:T.stroke),()=>s?e.stroke(s):e.stroke())}else e.fillStyle=T.paper,e.beginPath(),e.arc(a.x,a.y,a.radius,0,Math.PI*2),e.closePath(),e.fill(),e.strokeStyle=T.accent,e.lineWidth=T.badgeOutline*a.radius/T.badgeRadius,e.stroke(),e.fillStyle=T.ink,e.font=`600 ${a.font}px ${T.badgeFontFamily}`,e.textAlign="center",e.textBaseline="middle",e.fillText(a.label,a.x,a.y)}async function ba(e,t){const n=Uint8Array.from(atob(e),a=>a.charCodeAt(0));return createImageBitmap(new Blob([n],{type:t}))}async function ka(e){const t=await e.convertToBlob({type:"image/png"});return Ze(await t.arrayBuffer())}async function ht(e,t,n,a,r=0){await nn();const s=await ba(e.base64,e.mimeType);try{const i=Math.min(1,a/Math.max(t.width,t.height)),o=new OffscreenCanvas(Math.max(1,Math.round(t.width*i)),Math.max(1,Math.round(t.height*i))),l=o.getContext("2d");if(!l)throw new Error("dock-evidence-canvas-unavailable");return l.drawImage(s,0,0,o.width,o.height),wa(l,ya(t,n,i,r)),o}finally{s.close()}}async function va(e,t,n){const a=await ht(e,t,n,Math.max(t.width,t.height));return pa(await ka(a),"image/png")}async function Gr(e,t,n,a=384){const r=await ht(e,t,n,a,a/32);return URL.createObjectURL(await r.convertToBlob({type:"image/png"}))}function _a(e,t,n=T.arrowHead){const a=Math.atan2(t.y-e.y,t.x-e.x),r=T.arrowSpread;return{left:{x:t.x-n*Math.cos(a-r),y:t.y-n*Math.sin(a-r)},right:{x:t.x-n*Math.cos(a+r),y:t.y-n*Math.sin(a+r)}}}function Jr(e,t){const n=zt(t??void 0),a=new Set(t?.clips.filter(r=>!!r.media&&!F(r.media)).map(r=>r.contextItemId));return e.filter(r=>!n.has(r.id)&&!a.has(r.id))}async function Yr({workspaceId:e,agentId:t,evidence:n,clickedItems:a,sendItems:r,clickedPayload:s,binding:i,service:o,current:l,onRecord:c,timing:d}){const u=()=>{if(!l()||!G(i))throw new O("validate","media-send-retired")};if(u(),n?.images.some(w=>w.mediaError)||n?.clips.some(w=>w.mediaError))throw new O("validate","invalid-saved-edit");const h=w=>!!w.media&&!F(w.media),p=n?{workspaceId:e,agentId:t,appUrl:`intent://local/workspace/${encodeURIComponent(e)}`,clipAttachmentIds:Object.fromEntries(n.clips.map(w=>[w.id,a.find(M=>M.id===w.contextItemId)?.attachmentId??null]))}:null;for(const w of n?.clips??[]){if(!w.media||!F(w.media))continue;const M=a.find(Q=>Q.id===w.contextItemId);if(!M||M.attachmentId!==w.media.source.attachmentId||M.path!==w.media.source.path||M.placementStatus!==void 0&&M.placementStatus!=="placed")throw new O("validate","legacy-original-unavailable")}const m=n?await ua(e,n,i,o,l,d):{images:{},files:[],frames:[],framePromptBytes:[],metadata:[]},y=new Set(n?.clips.filter(w=>h(w)||!!w.media&&F(w.media)).map(w=>w.id)),f=new Set(n?.clips.filter(w=>y.has(w.id)).flatMap(w=>(w.captureHistory??[]).map(M=>M.image.id))),k=(n?.images??[]).filter(w=>w.source!=="annotate"||!!w.media||!f.has(w.id)||n.marks.some(M=>M.imageId===w.id&&!(M.clipId&&y.has(M.clipId))));d?.stage("burn");let v=[];try{v=n?await Sa({...n,images:k},a,m.images):[]}catch(w){throw new O("burn",ie(w))}if(m.framePromptBytes.reduce((w,M)=>w+(M??0),0)>Hn)throw new O("validate","image-budget-exceeded");const S=new Set(n?.images.filter(w=>w.media).map(w=>w.id)),_=n?{...n,images:k.map(w=>m.images[w.id]?{...w,width:m.images[w.id].width,height:m.images[w.id].height}:w),clips:n.clips.filter(w=>!h(w)),marks:n.marks.filter(w=>!S.has(w.imageId)&&!n.clips.some(M=>h(M)&&M.id===w.clipId))}:null;u();const B=m.metadata.some(w=>typeof w.transcript=="string"&&w.transcript.trim());if(!s.text.trim()&&!r.length&&!s.workspaceContextStr?.trim()&&!v.length&&!m.files.length&&!m.frames.length&&!s.imageBlocks?.length&&!s.fileBlocks?.length&&!B)return null;let C=v,P=null;d?.stage("placement");const xe=n?await pt(i):null;if(u(),n&&(e!==be||xe?.chiefAttachments)){const w=await ca({workspaceId:e,binding:i,images:k.map((M,Q)=>{const X=a.find(Et=>Et.id===M.contextItemId);return{image:M,signature:Gt(n,M.id),composite:{base64:v[Q].data,mimeType:v[Q].mimeType},raw:!M.media&&X?.imageData&&X.imageMimeType?{base64:X.imageData,mimeType:X.imageMimeType}:null}}),records:n?.placements??{},onRecord:c});u(),C=w.map(M=>({type:"image",attachmentId:M.composite.attachmentId,mimeType:M.composite.mimeType})),P=Object.fromEntries(w.map(M=>[M.imageId,{attachmentId:M.composite.attachmentId,raw:M.raw}]))}const g=new Map(n?Xe(n).map(({n:w,mark:M})=>[M.id,w]):[]),D=p&&P?{...p,imageAttachments:P,markNumbers:g}:p&&{...p,markNumbers:g},L=n&&D?{...s,imageBlocks:[...C,...m.frames,...s.imageBlocks??[]],fileBlocks:[...s.fileBlocks??[],...m.files],workspaceContextStr:[Yt(_,D),m.metadata.length?`[Edited capture outputs]
|
|
3
3
|
${JSON.stringify(m.metadata)}`:"",s.workspaceContextStr].filter(Boolean).join(`
|
|
4
4
|
|
|
5
5
|
`),messageMetadata:{...s.messageMetadata,...Jt(_,D),edited_captures:m.metadata}}:s;return u(),L}async function Sa(e,t,n={}){const a=Xe(e);return Promise.all(e.images.map(async r=>{if(n[r.id])return{type:"image",...n[r.id]};const s=t.find(o=>o.id===r.contextItemId);if(!s?.imageData||!s.imageMimeType)throw new Error("dock-evidence-missing-pixels");const i=await va({base64:s.imageData,mimeType:s.imageMimeType},r,a.filter(({mark:o})=>o.imageId===r.id));return{type:"image",data:i.base64,mimeType:i.mimeType}}))}function Ma(){return et()}function Qr(e){const{clip:t}=e;if(t.status!=="ready"||!t.path)return null;const n=e.marks.filter(s=>s.clipId===t.id&&typeof s.clipMs=="number").sort((s,i)=>s.clipMs-i.clipMs).map(s=>({id:s.id,tool:s.tool,atMs:s.clipMs,...s.element?.name?{label:s.element.name.slice(0,200)}:{}})),a=Qt(e.evidence??void 0,t.id),r=a?t.media:void 0;return{kind:"recording",workspaceId:e.workspaceId,agentId:e.agentId,attachmentId:a?.attachmentId??t.id,sourceRevision:a?`${a.id}:${a.revision}`:t.path,attachmentPath:t.path,title:"",durationMs:t.durationMs,marks:n,provenance:a?{...a.audio==="unknown"?{}:{hasMicAudio:a.audio==="available"},visuals:a.visuals}:{hasMicAudio:t.hasMicAudio,visuals:n.length>0?"baked-marks":"clean"},...a&&r?{source:a,saved:r.saved??null,transcript:r.transcript??null}:{}}}async function Xr(e){if(!Ma())return{ok:!1,error:"unavailable"};try{return await rn().invoke(an.OPEN,e)??{ok:!1,error:"unavailable"}}catch{return{ok:!1,error:"transport"}}}function Zr(e){let t=null,n=null;const a=o=>e.releaseMediaJob?.(o).catch(()=>{});function r(){const o=t;t=null,!(!o||o.taken||o.stopped)&&(o.stopped=!0,clearTimeout(o.timer),a(o.id))}function s(o,l,c){if(t?.key===o||n===o||(r(),n=null,!e.adoptMediaJob||!e.exportMedia||!c()||F(l)))return;const d=structuredClone(l),u=d.saved??re(d.source,d.source.capturedMarks??[],d.transcript),h=ve(u,d.source,d.transcript);if(d.source.kind!=="recording"||d.source.visuals!=="clean"||h.errors.length||!h.clips.length||u.voice==="transcript"&&d.transcript?.status!=="ready")return;const p={...d,saved:u},m=crypto.randomUUID(),y={key:o,mediaKey:JSON.stringify(p),id:m,current:c,taken:!1,stopped:!1,settled:!1,failed:!1,timer:setTimeout(()=>{t===y&&(n=o,r())},3e4),result:Promise.resolve({error:new Error("not-started")})};t=y,y.result=ot(p,m,e,()=>!y.stopped&&y.current()).then(async f=>y.stopped||!y.current()?(await a(m),{error:new Error("media-send-retired")}):{value:f},async f=>(y.failed=!0,t===y&&(n=o),await a(m),{error:f})).finally(()=>{y.settled=!0})}async function i(o,l,c){const d=t;if(!d||d.key!==o||d.mediaKey!==JSON.stringify(l)||d.stopped||d.taken||!c())return null;if(d.failed&&d.settled)return r(),null;d.taken=!0,d.current=c,clearTimeout(d.timer),t=null;const u=await d.result;if("error"in u)throw u.error;try{if(!c())throw new Error("media-send-retired");const h=await e.adoptMediaJob?.(d.id);if(!c())throw new Error("media-send-retired");return!h?.ok||!h.value?(await a(d.id),null):u.value}catch(h){throw await a(d.id),h}}return{warm:s,take:i,cancel:r}}function es(e={}){const t=a=>sn(a,typeof e=="function"?e():e),n=a=>bn(t(a));return{actionHints:{get capture(){return{label:b.dock_composer_screenshotAction_label(),shortcut:t("dock.capture")}},get record(){return{label:b.ui_shortcuts_dockRecord_label(),shortcut:t("dock.record")}},get dictate(){return{label:b.dock_shortcut_dictate_label()}}},get capture(){return b.dock_composer_capture_tooltip({shortcut:n("dock.capture")})},captureMode:{get window(){return b.dock_composer_captureWindow_tooltip({shortcut:n("dock.capture")})},get region(){return b.dock_composer_captureRegion_tooltip({shortcut:n("dock.capture")})}},captureModes:{fullscreen:b.dock_composer_captureFullscreen_label(),window:b.dock_composer_captureWindow_label(),region:b.dock_composer_captureRegion_label()},captureOptions:b.dock_composer_captureModes_ariaLabel(),captureLimit:b.dock_composer_captureLimit_tooltip(),clipLimit:b.dock_composer_clipLimit_tooltip({limit:q(ae.clips)}),get record(){return b.dock_composer_record_tooltip({shortcut:n("dock.record")})},stopRecording:b.dock_composer_stopRecording_tooltip(),annotationTools:b.annotation_toolbar_ariaLabel(),annotateCurrent:a=>b.dock_composer_annotate_ariaLabel({tool:a}),tools:{pick:b.dock_composer_pick_label(),box:b.dock_composer_box_label(),pen:b.dock_composer_pen_label(),arrow:b.annotation_arrow_label()},get dictate(){return b.dock_shortcut_dictate_label()},stopDictating:b.dock_composer_stopDictating_tooltip(),annotating:b.dock_composer_annotating_status(),recording:b.dock_composer_recording_status(),markUp:b.dock_composer_markUp_label(),remove:b.chat_contextChip_remove_label(),play:b.dock_composer_play_label(),edit:b.dock_composer_edit_label(),done:b.dock_composer_done_label(),attachments:b.context_attachments_title_label(),retry:b.chat_shared_retry_label(),attachmentPending:b.dock_composer_attachmentPending_status(),attachmentFailed:b.dock_composer_attachmentFailed_error(),image:a=>b.dock_composer_image_ariaLabel({n:q(a)}),clip:a=>b.dock_composer_clip_ariaLabel({duration:a}),recordingReference:(a,r)=>r?b.dock_composer_recordingEnd_chip({n:q(a)}):b.dock_composer_recordingStart_chip({n:q(a)}),speechError:a=>a.includes("permission")?b.dock_composer_speechPermission_error():["unsupported-platform","helper-missing","recognizer-unavailable","locale-unsupported","assets-unavailable","unavailable"].includes(a)?b.dock_composer_speechUnavailable_error():b.dock_composer_speechFailed_error()}}function ts(e,t){return{enabled:e,limit:ae.files,excludedIds:t,unavailableMessage:b.dock_composer_filesUnavailable_error(),limitMessage:b.dock_composer_fileLimit_error({limit:q(ae.files)})}}function Aa(e){try{return new URL(e.pageUrl).hostname||e.pageUrl}catch{return e.pageUrl}}function ns(e,t){return e.targetAgentId===t}function as(e){const t=e.element,n=e.viewport,a=Aa(e),r=t?`<${t.tagName.toLowerCase()}> · ${a}`:e.title||a,s=["<browser-element-capture>",`Page URL: ${e.pageUrl}`,`Page title: ${e.title}`,...t?[`DOM path: ${t.domPath}`,`CSS selector: ${t.selector}`,`Text snippet: ${t.textSnippet}`,...t.sourceRef?[`Source ref: ${t.sourceRef}`]:[],...n?[`Viewport: ${n.width}×${n.height}`]:[],`Element bounds: ${t.rect.width}×${t.rect.height} at (${t.rect.x}, ${t.rect.y})`]:[],"</browser-element-capture>"].join(`
|
|
@@ -8,5 +8,5 @@ ${JSON.stringify(m.metadata)}`:"",s.workspaceContextStr].filter(Boolean).join(`
|
|
|
8
8
|
\`\`\`
|
|
9
9
|
${i}
|
|
10
10
|
\`\`\`]`)}return Ia(a.join(`
|
|
11
|
-
`),e)}function rs(e,t,n){if(e==="suggested-prompt")return{fields:{},hasAttachments:!1,cleanup:{clearInput:!1,followBottom:!0,historyText:null}};const a=n(),{imageBlocks:r,fileBlocks:s}=Ta(a.contextItems);return{fields:{contextItems:a.contextItems,workspaceContextStr:Ea(a.contextItems,a.checkedPanels,a.checkedSelections),noteIds:a.noteIds,...r.length>0?{imageBlocks:r}:{},...s.length>0?{fileBlocks:s}:{},...a.pickedMentions?{messageMetadata:a.pickedMentions}:{}},hasAttachments:r.length>0||s.length>0,cleanup:{clearInput:!0,followBottom:!0,historyText:t}}}const Ca="chat-read:",K=new Map,ye=new Set;function ss(e,t){let n=K.get(e);n||(n=new Set,K.set(e,n)),n.add(t)}function is(e,t){const n=K.get(e);if(!(!n||!n.delete(t))&&n.size===0){K.delete(e);for(const a of[...ye])a(e)}}function os(e){return ye.add(e),()=>ye.delete(e)}function cs(e){return K.has(e)}function ls(e){const t=K.get(e);if(!t)return!1;for(const n of t)if(!n.startsWith(Ca))return!0;return!1}function Da(e,t,n){const a=e.state.pendingSubmissions.byAgentId[t.agentId];if(!a||!Ge(a.scope,t))return null;const r={...structuredClone(n),id:crypto.randomUUID(),createdAt:Date.now()};e.dispatch(xt(t,r));const s=e.state.pendingSubmissions.byAgentId[t.agentId];return s&&R(s.submissions,r.id)?r:null}function Ra(e,t,n,a,r){const s=Be.select(e.state,n),i=pe.select(e.state)?.principal.id,o=Ue(e.state);if(!s||!i||!o)return null;const l=An(t,n),c={agentId:t,workspaceId:n,principalId:i,participation:s,authority:o,owner:l.key,lifetime:e.state.pendingSubmissions.byAgentId[t]?.scope.lifetime??crypto.randomUUID()},d=()=>l.isCurrent(e.state.agentSessions?.byAgentId[t]?.workspaceId)&&Be.select(e.state,n)===s&&pe.select(e.state)?.principal.id===i&&Ue(e.state)===o;if(!d())return null;e.dispatch(Rt(c,a,Ft.select(e.state,n)));const u=Da(e,c,r);return u?{scope:c,submission:u,isCurrent:()=>{const h=e.state.pendingSubmissions.byAgentId[t];return d()&&!!h&&Ge(h.scope,c)&&(!!R(h.operations,u.id)||!!R(h.submissions,u.id))}}:null}function we(e,t,n){if(!n.text.trim()&&!n.imageBlocks?.length&&!n.fileBlocks?.length)return null;const a=n.userAppMessageId??In();return Ra(e,t,n.wsId,pe.select(e.state)?.capabilities.submissionCorrelation,{content:n.text.trim(),appMessageId:a,destination:!n.forceSubmit&&Kt.select(e.state,t)?"queue":"conversation",contextItems:n.contextItems,imageBlocks:n.imageBlocks,fileBlocks:n.fileBlocks,messageMetadata:n.messageMetadata})}function xa(e,t,n){const a=we(e,t,n);return a?(e.dispatch(Je(t,{...n,userAppMessageId:a.submission.appMessageId,submission:{scope:a.scope,id:a.submission.id}})),!0):!1}async function Pa(e,t,n,a){const r=n.submission;if(!r)return"legacy";const s=r.reference,i=()=>s.scope.agentId===e&&s.scope.workspaceId===t&&Qe.select(A.state,e)===n?gn.select(A.state,s.scope):void 0,o=i();if(!o)return null;if(!o.supported)return"legacy";const l={wsId:t,text:n.text,imageBlocks:n.options?.imageBlocks,fileBlocks:n.options?.fileBlocks,noteIds:n.options?.noteIds,messageMetadata:n.options?.messageMetadata,model:a??n.options?.model};if(r.outcome==="rejected"){const p=R(o.tombstones,s.id);return R(o.submissions,s.id)||p&&p.reason!=="rejected"?null:we(A,e,l)}if(r.outcome==="accepted")return we(A,e,l);await Promise.all([Tn(e,t).catch(()=>{}),En(e,t).catch(()=>{})]);const c=i();if(!c||R(c.submissions,s.id)?.status!=="uncertain")return null;const{notify:d}=await fe(async()=>{const{notify:p}=await import("./7i9XTDuo.js").then(m=>m.u);return{notify:p}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45]),import.meta.url);if(i()!==c)return null;let u=!1;const h=()=>{u=!0};return d.warning(b.agent_chatSend_uncertainRetry_description(),{key:`submission-retry:${t}:${e}:${s.id}`,duration:Number.POSITIVE_INFINITY,action:{label:b.agent_chatSend_resend_label(),onClick:()=>{if(u)return;u=!0;const p=i();!p||p.generation!==c.generation||p.submissions!==c.submissions||p.observationVersion!==c.observationVersion||R(p.submissions,s.id)?.status!=="uncertain"||xa(A,e,l)}},cancel:{label:b.chat_richInput_cancel_label(),onClick:h},onDismiss:h}),null}async function ds(e,t,n){const a=Qe.select(A.state,e),r=a?.submission?await Pa(e,t,a,n):"legacy";if(r){if(r==="legacy"){await A.dispatch(n===void 0?Pt(e,t):Bt(e,t,n));return}!r.isCurrent()||!a||A.dispatch(Je(e,{wsId:t,text:a.text,imageBlocks:a.options?.imageBlocks,fileBlocks:a.options?.fileBlocks,noteIds:a.options?.noteIds,messageMetadata:a.options?.messageMetadata,model:n??a.options?.model,userAppMessageId:r.submission.appMessageId,submission:{scope:r.scope,id:r.submission.id}}))}}const us=A.createSelector((e,t)=>{const n=R(e.chatDrafts.owners,t);return n?{restore:n.restore,saves:Ye(n.saves),shared:n.restore?e.chatDrafts.shared[JSON.stringify([n.restore.workspaceId,n.restore.agentId])]:void 0}:void 0});function Ba(e,t){return t.workspaceId===e&&!t.retiredAt&&!t.pendingDeleteAt&&t.status!==ke.Deleted&&!t.notificationsMuted&&$t(t)==="topLevel"}function Oa(e){const t=e.metadata?.pendingQuestionsMessageId;return typeof t=="string"&&t.length>0&&!Rn(e.metadata,t)?t:null}function $a(e){return e.status===ke.Error&&!Wt(jt(e))}function ms(e,t){return t.filter(n=>Ba(e,n)).flatMap(n=>{const a=Ot(n),r=Oa(n),s=n.status===ke.Error;if(!a&&!r&&!s)return[];const i=a?.timestamp??(s?n.stopReasonTimestamp:void 0);return[{agentId:n.id,agentName:n.name,kind:a?.kind??(s?"failed":"question"),reason:a?.reason,timestamp:i&&Number.isFinite(Date.parse(i))?i:void 0,questionMessageId:r,canRetry:$a(n)}]})}function ps(e){return e.displayStatus==="failed"?"failed":e.displayStatus==="blocked"?"blocked":e.attention==="review_required"?"review":e.displayStatus==="needs_attention"?"question":e.activity==="agent_running"||e.displayStatus==="in_progress"?"running":e.scriptsRunning===!0?"scripts_running":e.backgroundTasksRunning===!0?"background_tasks_running":e.displayStatus==="pr_ready"?"pr_ready":e.displayStatus==="pr_merged"?"merged":e.displayStatus==="complete"?"complete":e.attention==="unread"?"unread":e.displayStatus==="pr_open"||e.displayStatus==="pr_queued"?e.displayStatus:"idle"}function fs(e){const t=e.kind==="prs"?e.organization?.trim().toLowerCase():void 0;return{key:JSON.stringify([e.kind,e.workspaceId,t||null,[...new Set((t?[]:e.repositories).map(n=>JSON.stringify([n.key,n.owner,n.name])))].sort()]),hasGitHubRepositories:!!t||e.repositories.some(n=>!!n.owner),hasLocalRepositories:!t&&e.repositories.some(n=>!n.owner)}}function Te(e){const t=kn(e);if(t?.kind!=="pr"||!Number.isSafeInteger(t.number)||t.number<=0)return null;const n=t.owner.toLowerCase(),a=t.repo.toLowerCase();return{owner:n,repo:a,number:t.number,id:`${n}/${a}#${t.number}`,url:`https://github.com/${n}/${a}/pull/${t.number}`}}function hs(e,t,n,a){const r=e.filter(s=>a?a.includes(s.id):n?s.repositoryOwner?.toLowerCase()===n.toLowerCase():t.some(i=>i.owner?.toLowerCase()===s.repositoryOwner?.toLowerCase()&&i.name.toLowerCase()===s.repositoryName?.toLowerCase()));return[...new Map(r.flatMap(s=>[...(s.pullRequests??[]).map(i=>i.url),s.activePullRequest?.url,s.prUrl]).flatMap(s=>{const i=s?Te(s):null;return i?[[i.id,{owner:i.owner,repo:i.repo,number:i.number}]]:[]})).values()].sort((s,i)=>`${s.owner}/${s.repo}#${s.number}`.localeCompare(`${i.owner}/${i.repo}#${i.number}`))}function gs(e,t){const[n]=t;return t.length!==1||e.owner?.toLowerCase()!==n?.owner?.toLowerCase()||e.repo?.toLowerCase()!==n?.name.toLowerCase()}const ys=A.createSelector(e=>e.homeIntegrations),ws=A.createSelector(e=>{const t=e.homeIntegrations;return!t.linkedItems||!Object.keys(t.linkedItems).length?t:{...t,items:[...new Map([...Object.values(t.linkedItems),...t.items].map(n=>[n.id,n])).values()].sort((n,a)=>(a.updatedAt??"").localeCompare(n.updatedAt??""))}}),gt=A.createSelector(e=>Ye(e.workspace.workspaces).flatMap(t=>[...(t.pullRequests??[]).map(n=>n.url),t.activePullRequest?.url,t.prUrl].filter(n=>!!n).map(n=>({url:Te(n)?.url??n.replace(/\/$/,"").toLowerCase(),workspaceId:t.id,name:t.title||t.id})))),bs=A.createSelector(e=>{const t=e.homeIntegrations.detail?.url,n=t?Te(t)?.url??t.replace(/\/$/,"").toLowerCase():void 0;return gt.select(e).find(a=>a.url===n)??null}),ks=A.createSelector(e=>gt.select(e).map(t=>t.url));let ee=null;function vs(e){return ee=e,()=>{ee===e&&(ee=null)}}function _s(){return ee}function Ss(e){return[...e.groups.length>0?e.groups.filter(n=>n.expanded).flatMap(n=>n.items):e.workspaces,...e.asideExpanded?e.aside:[]].map(n=>n.id)}function Ms(e,t,n){if(e.length===0)return null;const a=t===null?-1:e.indexOf(t);return a===-1?e[0]:e[a+(n==="clockwise"?1:-1)]??null}let te=null;function As(e){return te=e,()=>{te===e&&(te=null)}}function Is(){return te}function Ts(e){return Mn(e)}function Ua(e){return Sn(e)}function La(e,t){return!e||!t?!1:e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function me(e){if(e.length===0)return[];const t=[];let n=null;for(const a of e){const r=a.timestamp?typeof a.timestamp=="string"?new Date(a.timestamp):a.timestamp:new Date;(!n||!La(n.date,r))&&(n={date:r,label:Ua(r),messages:[]},t.push(n)),n.messages.push(a)}return t}function Es(e){const t=new Map;return e.map(({date:n})=>{const a=`${n.getFullYear()}-${n.getMonth()+1}-${n.getDate()}`,r=t.get(a)??0;return t.set(a,r+1),r===0?a:`${a}#${r}`})}function Cs(e,t){const n=new Map;let a=t?null:void 0;for(const r of e.groups)for(const s of r.messages)a!==void 0&&n.set(s.id,a),s.role==="user"&&!Pn(s)&&(a=s);return n}function Na(e){return`${e.getFullYear()}-${e.getMonth()+1}-${e.getDate()}`}function je(e,t){const n=new Map;return e.map(a=>{const r=`${t}-${Na(a.date)}`,s=(n.get(r)??0)+1;return n.set(r,s),{...a,groupKey:s===1?r:`${r}-${s}`}})}function Ha(e,t){if(e.length===0||t.length===0)return e;const n=new Set(t.map(s=>s.id)),a=new Set(t.map(s=>s.appMessageId).filter(s=>typeof s=="string"&&s.length>0)),r=e.filter(s=>!n.has(s.id)&&!(typeof s.appMessageId=="string"&&s.appMessageId.length>0&&a.has(s.appMessageId)));return r.length===e.length?e:r}function Ds(e,t,n){return e=Ha(e,t),e.length===0?{groups:me(t),detached:!1,hiddenTail:[]}:n?{groups:je(me(e),"h"),detached:!0,hiddenTail:t}:{groups:je(me([...e,...t]),"d"),detached:!1,hiddenTail:[]}}function Rs(e){const{scrollTop:t,threshold:n,fetching:a,exhausted:r,historyCount:s,tailCount:i,tailTruncated:o,totalMessages:l,spacerAbove:c=0}=e;return t>n+c||a||r?!1:s>0||o||l>i+s}const xs=300;function Ps(e){const{fetching:t,chainEvaluationPending:n,visible:a,hideArmed:r}=e;return t||n?a&&!r?"none":"show":a&&!r?"arm-hide":"none"}const qe=24,Fa=320;function Ee(e){return Number.isFinite(e)?Math.min(Fa,Math.max(qe,e)):qe}const Ka=.2,Wa=.12;function ja(e,t,n=Ka){const a=Ee(t);return e===null||!Number.isFinite(e)?a:e+n*(a-e)}function Bs(e,t){const n=Ee(t??Number.NaN);return{above:Math.round(Math.max(0,e.above)*n),below:Math.round(Math.max(0,e.below)*n)}}function Os(e){const{totalMessages:t,residentCount:n,exhausted:a,residentContentHeight:r,currentSpacerHeight:s,viewportHeight:i}=e;let o=e.rowHeightEma;n>0&&r>0&&(o=ja(o,r/n));const l=e.unloadedRows??t-n,d=a||t<=0||n<=0||l<=0||o===null?0:Math.round(l*o),u=Math.abs(d-s);return u===0?{spacerHeight:s,rowHeightEma:o,applied:!1,scrollTopDelta:0}:d===0||s===0||u>s*Wa||i>0&&u>i?{spacerHeight:d,rowHeightEma:o,applied:!0,scrollTopDelta:d-s}:{spacerHeight:s,rowHeightEma:o,applied:!1,scrollTopDelta:0}}const qa=xn,Va=2;function $s(e){const{scrollTop:t,spacerAboveHeight:n,rowHeightEstimate:a,pageSize:r=qa,nearPages:s=Va}=e;if(n<=0||t>=n)return"serial";const i=Ee(a??Number.NaN);return(n-Math.max(0,t))/i>s*r?"seek":"serial"}const yt=200,za=1;function Us(e,t,n=yt){const a=t.timestamp-n;return[...e.filter(r=>r.timestamp>=a),t]}function Ls(e){const{samples:t,viewportHeight:n,windowMs:a=yt,viewportFactor:r=za}=e;if(n<=0||t.length<2)return"gentle";const s=t[t.length-1].timestamp-a,i=t.filter(l=>l.timestamp>=s);if(i.length<2)return"gentle";let o=0;for(let l=1;l<i.length;l+=1)o+=Math.abs(i[l].scrollTop-i[l-1].scrollTop);return o>n*r?"rapid":"gentle"}function Ns(e){const{scrollTop:t,spacerAboveHeight:n,unloadedRowsAbove:a}=e;if(a<=0||n<=0)return 0;const r=Math.min(1,Math.max(0,t/n));return Math.min(a-1,Math.max(0,Math.floor(r*a)))}function Hs(e){const{totalMessages:t,residentCount:n,exhausted:a,startOrdinalEstimate:r,detachedFromTail:s}=e,i=Math.max(0,t-n);if(!s)return{above:a?0:i,below:0};const o=Math.max(0,e.hiddenTailCount??0);if(a)return{above:0,below:i+o};if(r!==null){const c=Math.min(i,Math.max(0,Math.round(r)));return{above:c,below:i-c+o}}const l=Math.min(i,Math.max(0,Math.round(e.holeRowsEstimate??0)));return{above:i-l,below:l+o}}function Fs(e){const{exhausted:t,historyCount:n,tailCount:a,tailTruncated:r,totalMessages:s}=e;return t?!0:n>0?!1:!r&&s<=a}const Ga="intent.drafts.sync",Ja="intent.drafts.changed",Ya=$({id:E(),type:E(),label:E(),description:E().optional(),content:E().optional(),path:E().optional(),imageData:E().optional(),imageMimeType:E().optional(),attachmentId:E().optional(),attachmentMimeType:E().optional(),attachmentSize:ce().optional(),sourcePath:E().optional(),placementStatus:V("failed").optional(),screen:Bn().optional()}),wt=$({text:E(),attachments:On(Ya)}),z={provenance:E().min(1),workspaceId:E().min(1),agentId:E().min(1)},ne={lifetime:E(),revision:ce().int().nonnegative()};$n("kind",[$({...z,kind:V("read")}),$({...z,...ne,kind:V("edit"),origin:E().min(1),sequence:ce().int().positive(),snapshot:wt}),$({...z,...ne,kind:V("flush")}),$({...z,...ne,kind:V("clear"),origin:E().min(1)})]);const bt=$({...z,...ne,origin:E(),sequence:ce().int().nonnegative(),snapshot:wt}),Qa=$({accepted:Un(),draft:bt});function Xa(e,t,n=t){const a=new Map,r=new Set,s=crypto.randomUUID();let i=0,o=!1;const l=()=>{const f=t();if(o||!f)throw new Error("draft-authority-unavailable");return f},c=()=>{const f=n();if(!f||o)throw new Error("draft-authority-unavailable");return()=>{if(o||n()!==f)throw new Error("draft-authority-changed")}},d=(f,k,v)=>{const I=JSON.stringify([f,k,v]);let S=a.get(I);return S||(S={dirty:0},a.set(I,S)),S},u=(f,k)=>{if(o||f.provenance!==t())return;const v=d(f.provenance,f.workspaceId,f.agentId);if(!(v.value?.lifetime===f.lifetime&&v.value.revision>f.revision)&&(v.value=f,k&&v.dirty===0))for(const I of r)I(f)},h=e.subscribe(f=>{const k=bt.safeParse(f);k.success&&u(k.data,!0)}),p=async(f,k)=>{k();const v=Qa.parse(await e.request(f));if(k(),f.provenance!==l()||v.draft.provenance!==f.provenance)throw new Error("draft-authority-changed");if(!v.accepted)throw u(v.draft,!1),new Error("draft-changed-in-another-editor");return v.draft},m=async(f,k)=>{const v=l(),I=c(),S=d(v,f,k);S.tail&&await S.tail;const _=await p({kind:"read",provenance:v,workspaceId:f,agentId:k},I);return u(_,!1),_},y=(f,k,v)=>{const I=l(),S=c(),_=d(I,f,k),B=_.tail??(_.value?Promise.resolve(_.value):p({kind:"read",provenance:I,workspaceId:f,agentId:k},S));_.dirty+=1;const C=B.then(P=>p(v(P),S));return _.tail=C,C.then(P=>{_.dirty-=1,_.tail===C&&(_.tail=void 0),u(P,!0)},()=>{_.dirty-=1,_.tail===C&&(_.tail=void 0)}),C};return{authority:()=>o?null:n(),read:m,async edit(f,k,v,I){const S=++i;return y(k,v,_=>({kind:"edit",provenance:_.provenance,workspaceId:k,agentId:v,lifetime:_.lifetime,revision:_.revision,origin:f,sequence:S,snapshot:I}))},async flush(f,k){const v=l(),I=c(),S=d(v,f,k),_=await(S.tail??(S.value?Promise.resolve(S.value):m(f,k)));await p({kind:"flush",provenance:v,workspaceId:f,agentId:k,lifetime:_.lifetime,revision:_.revision},I)},async clear(f,k){await y(f,k,v=>({kind:"clear",provenance:v.provenance,workspaceId:f,agentId:k,lifetime:v.lifetime,revision:v.revision,origin:s}))},subscribe(f){return r.add(f),()=>{r.delete(f)}},dispose(){o=!0,h(),r.clear(),a.clear()}}}let U=null;async function Ks(e,t,n,a,r){const s=U;if(!s)throw new Error("draft-shared-transport-unavailable");const i=()=>{if(U!==s||s.authority()!==r)throw new Error("draft-authority-changed")};i(),await s.edit(e,t,n,a),i(),await s.flush(t,n),i()}async function Ws(e,t){await Promise.resolve(),U&&await U.flush(e,t)}function js(){if(!et())return null;const e=Xa({request:n=>_n(Ga,n),subscribe:n=>vn(a=>{a.method===Ja&&n(a.params)})},()=>Cn(A.state),()=>Dn(A.state));U=e;const t=e.dispose;return e.dispose=()=>{U===e&&(U=null),t()},e}const kt=new Map;function vt(e,t){return`${e}\0${t}`}function qs(e,t){return kt.get(vt(e,t))}function Vs(e,t,n){kt.set(vt(e,t),n)}const zs=A.createSelector((e,t,n)=>{const a=e.chatPanelUi.byWorkspaceId[t];return a?R(a.userMessageIndexes,n):void 0}),Gs=A.createSelector((e,t,n)=>{const a=e.chatPanelUi.byWorkspaceId[t];return a?R(a.retryAgents,n):void 0});function Za(e){e=Math.max(0,e);const t=Math.floor(e/1e3);if(t<10){const s=e/1e3,i=s.toFixed(1);return i.endsWith(".0")?`${Math.round(s)}s`:`${i}s`}if(t<60)return`${t}s`;const n=Math.floor(t/3600),a=Math.floor(t%3600/60),r=t%60;return n>0?`${n}h ${a}m ${r}s`:`${a}m ${r}s`}function Js(e){return Za(Math.max(1e3,Math.round(e/1e3)*1e3))}const er=new Set(["launch","init","session-create","session-load","prompt"]),tr=new Set(["tool-call","tool-waiting"]);function nr(e){let t=null;for(const n of e)(!t||n.timestamp>=t.timestamp)&&(t=n);return t}function Ys(e){return e&&er.has(e)?"pulse":e&&tr.has(e)?"twist":"bloom"}const _t="stalled";function Qs(e,t){const n=nr(e);return!n||n.phase!==_t||typeof t=="number"&&t>n.timestamp?null:n}function Xs(e){let t=null;for(const n of e)n.phase!==_t&&(!t||n.timestamp>=t.timestamp)&&(t=n);return t}const Ve={get title(){return b.chat_streamingStatus_sessionCorrupted_title()},get message(){return b.chat_streamingStatus_sessionCorrupted_message()}},ar=/^session\/[a-z_]+(?: failed)?:\s*/i;function rr(e){const n=(e.split(`
|
|
11
|
+
`),e)}function rs(e,t,n){if(e==="suggested-prompt")return{fields:{},hasAttachments:!1,cleanup:{clearInput:!1,followBottom:!0,historyText:null}};const a=n(),{imageBlocks:r,fileBlocks:s}=Ta(a.contextItems);return{fields:{contextItems:a.contextItems,workspaceContextStr:Ea(a.contextItems,a.checkedPanels,a.checkedSelections),noteIds:a.noteIds,...r.length>0?{imageBlocks:r}:{},...s.length>0?{fileBlocks:s}:{},...a.pickedMentions?{messageMetadata:a.pickedMentions}:{}},hasAttachments:r.length>0||s.length>0,cleanup:{clearInput:!0,followBottom:!0,historyText:t}}}const Ca="chat-read:",K=new Map,ye=new Set;function ss(e,t){let n=K.get(e);n||(n=new Set,K.set(e,n)),n.add(t)}function is(e,t){const n=K.get(e);if(!(!n||!n.delete(t))&&n.size===0){K.delete(e);for(const a of[...ye])a(e)}}function os(e){return ye.add(e),()=>ye.delete(e)}function cs(e){return K.has(e)}function ls(e){const t=K.get(e);if(!t)return!1;for(const n of t)if(!n.startsWith(Ca))return!0;return!1}function Da(e,t,n){const a=e.state.pendingSubmissions.byAgentId[t.agentId];if(!a||!Ge(a.scope,t))return null;const r={...structuredClone(n),id:crypto.randomUUID(),createdAt:Date.now()};e.dispatch(xt(t,r));const s=e.state.pendingSubmissions.byAgentId[t.agentId];return s&&R(s.submissions,r.id)?r:null}function Ra(e,t,n,a,r){const s=Be.select(e.state,n),i=pe.select(e.state)?.principal.id,o=Ue(e.state);if(!s||!i||!o)return null;const l=An(t,n),c={agentId:t,workspaceId:n,principalId:i,participation:s,authority:o,owner:l.key,lifetime:e.state.pendingSubmissions.byAgentId[t]?.scope.lifetime??crypto.randomUUID()},d=()=>l.isCurrent(e.state.agentSessions?.byAgentId[t]?.workspaceId)&&Be.select(e.state,n)===s&&pe.select(e.state)?.principal.id===i&&Ue(e.state)===o;if(!d())return null;e.dispatch(Rt(c,a,Ft.select(e.state,n)));const u=Da(e,c,r);return u?{scope:c,submission:u,isCurrent:()=>{const h=e.state.pendingSubmissions.byAgentId[t];return d()&&!!h&&Ge(h.scope,c)&&(!!R(h.operations,u.id)||!!R(h.submissions,u.id))}}:null}function we(e,t,n){if(!n.text.trim()&&!n.imageBlocks?.length&&!n.fileBlocks?.length)return null;const a=n.userAppMessageId??In();return Ra(e,t,n.wsId,pe.select(e.state)?.capabilities.submissionCorrelation,{content:n.text.trim(),appMessageId:a,destination:!n.forceSubmit&&Kt.select(e.state,t)?"queue":"conversation",contextItems:n.contextItems,imageBlocks:n.imageBlocks,fileBlocks:n.fileBlocks,messageMetadata:n.messageMetadata})}function xa(e,t,n){const a=we(e,t,n);return a?(e.dispatch(Je(t,{...n,userAppMessageId:a.submission.appMessageId,submission:{scope:a.scope,id:a.submission.id}})),!0):!1}async function Pa(e,t,n,a){const r=n.submission;if(!r)return"legacy";const s=r.reference,i=()=>s.scope.agentId===e&&s.scope.workspaceId===t&&Qe.select(A.state,e)===n?gn.select(A.state,s.scope):void 0,o=i();if(!o)return null;if(!o.supported)return"legacy";const l={wsId:t,text:n.text,imageBlocks:n.options?.imageBlocks,fileBlocks:n.options?.fileBlocks,noteIds:n.options?.noteIds,messageMetadata:n.options?.messageMetadata,model:a??n.options?.model};if(r.outcome==="rejected"){const p=R(o.tombstones,s.id);return R(o.submissions,s.id)||p&&p.reason!=="rejected"?null:we(A,e,l)}if(r.outcome==="accepted")return we(A,e,l);await Promise.all([Tn(e,t).catch(()=>{}),En(e,t).catch(()=>{})]);const c=i();if(!c||R(c.submissions,s.id)?.status!=="uncertain")return null;const{notify:d}=await fe(async()=>{const{notify:p}=await import("./CoZeNthD.js").then(m=>m.u);return{notify:p}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45]),import.meta.url);if(i()!==c)return null;let u=!1;const h=()=>{u=!0};return d.warning(b.agent_chatSend_uncertainRetry_description(),{key:`submission-retry:${t}:${e}:${s.id}`,duration:Number.POSITIVE_INFINITY,action:{label:b.agent_chatSend_resend_label(),onClick:()=>{if(u)return;u=!0;const p=i();!p||p.generation!==c.generation||p.submissions!==c.submissions||p.observationVersion!==c.observationVersion||R(p.submissions,s.id)?.status!=="uncertain"||xa(A,e,l)}},cancel:{label:b.chat_richInput_cancel_label(),onClick:h},onDismiss:h}),null}async function ds(e,t,n){const a=Qe.select(A.state,e),r=a?.submission?await Pa(e,t,a,n):"legacy";if(r){if(r==="legacy"){await A.dispatch(n===void 0?Pt(e,t):Bt(e,t,n));return}!r.isCurrent()||!a||A.dispatch(Je(e,{wsId:t,text:a.text,imageBlocks:a.options?.imageBlocks,fileBlocks:a.options?.fileBlocks,noteIds:a.options?.noteIds,messageMetadata:a.options?.messageMetadata,model:n??a.options?.model,userAppMessageId:r.submission.appMessageId,submission:{scope:r.scope,id:r.submission.id}}))}}const us=A.createSelector((e,t)=>{const n=R(e.chatDrafts.owners,t);return n?{restore:n.restore,saves:Ye(n.saves),shared:n.restore?e.chatDrafts.shared[JSON.stringify([n.restore.workspaceId,n.restore.agentId])]:void 0}:void 0});function Ba(e,t){return t.workspaceId===e&&!t.retiredAt&&!t.pendingDeleteAt&&t.status!==ke.Deleted&&!t.notificationsMuted&&$t(t)==="topLevel"}function Oa(e){const t=e.metadata?.pendingQuestionsMessageId;return typeof t=="string"&&t.length>0&&!Rn(e.metadata,t)?t:null}function $a(e){return e.status===ke.Error&&!Wt(jt(e))}function ms(e,t){return t.filter(n=>Ba(e,n)).flatMap(n=>{const a=Ot(n),r=Oa(n),s=n.status===ke.Error;if(!a&&!r&&!s)return[];const i=a?.timestamp??(s?n.stopReasonTimestamp:void 0);return[{agentId:n.id,agentName:n.name,kind:a?.kind??(s?"failed":"question"),reason:a?.reason,timestamp:i&&Number.isFinite(Date.parse(i))?i:void 0,questionMessageId:r,canRetry:$a(n)}]})}function ps(e){return e.displayStatus==="failed"?"failed":e.displayStatus==="blocked"?"blocked":e.attention==="review_required"?"review":e.displayStatus==="needs_attention"?"question":e.activity==="agent_running"||e.displayStatus==="in_progress"?"running":e.scriptsRunning===!0?"scripts_running":e.backgroundTasksRunning===!0?"background_tasks_running":e.displayStatus==="pr_ready"?"pr_ready":e.displayStatus==="pr_merged"?"merged":e.displayStatus==="complete"?"complete":e.attention==="unread"?"unread":e.displayStatus==="pr_open"||e.displayStatus==="pr_queued"?e.displayStatus:"idle"}function fs(e){const t=e.kind==="prs"?e.organization?.trim().toLowerCase():void 0;return{key:JSON.stringify([e.kind,e.workspaceId,t||null,[...new Set((t?[]:e.repositories).map(n=>JSON.stringify([n.key,n.owner,n.name])))].sort()]),hasGitHubRepositories:!!t||e.repositories.some(n=>!!n.owner),hasLocalRepositories:!t&&e.repositories.some(n=>!n.owner)}}function Te(e){const t=kn(e);if(t?.kind!=="pr"||!Number.isSafeInteger(t.number)||t.number<=0)return null;const n=t.owner.toLowerCase(),a=t.repo.toLowerCase();return{owner:n,repo:a,number:t.number,id:`${n}/${a}#${t.number}`,url:`https://github.com/${n}/${a}/pull/${t.number}`}}function hs(e,t,n,a){const r=e.filter(s=>a?a.includes(s.id):n?s.repositoryOwner?.toLowerCase()===n.toLowerCase():t.some(i=>i.owner?.toLowerCase()===s.repositoryOwner?.toLowerCase()&&i.name.toLowerCase()===s.repositoryName?.toLowerCase()));return[...new Map(r.flatMap(s=>[...(s.pullRequests??[]).map(i=>i.url),s.activePullRequest?.url,s.prUrl]).flatMap(s=>{const i=s?Te(s):null;return i?[[i.id,{owner:i.owner,repo:i.repo,number:i.number}]]:[]})).values()].sort((s,i)=>`${s.owner}/${s.repo}#${s.number}`.localeCompare(`${i.owner}/${i.repo}#${i.number}`))}function gs(e,t){const[n]=t;return t.length!==1||e.owner?.toLowerCase()!==n?.owner?.toLowerCase()||e.repo?.toLowerCase()!==n?.name.toLowerCase()}const ys=A.createSelector(e=>e.homeIntegrations),ws=A.createSelector(e=>{const t=e.homeIntegrations;return!t.linkedItems||!Object.keys(t.linkedItems).length?t:{...t,items:[...new Map([...Object.values(t.linkedItems),...t.items].map(n=>[n.id,n])).values()].sort((n,a)=>(a.updatedAt??"").localeCompare(n.updatedAt??""))}}),gt=A.createSelector(e=>Ye(e.workspace.workspaces).flatMap(t=>[...(t.pullRequests??[]).map(n=>n.url),t.activePullRequest?.url,t.prUrl].filter(n=>!!n).map(n=>({url:Te(n)?.url??n.replace(/\/$/,"").toLowerCase(),workspaceId:t.id,name:t.title||t.id})))),bs=A.createSelector(e=>{const t=e.homeIntegrations.detail?.url,n=t?Te(t)?.url??t.replace(/\/$/,"").toLowerCase():void 0;return gt.select(e).find(a=>a.url===n)??null}),ks=A.createSelector(e=>gt.select(e).map(t=>t.url));let ee=null;function vs(e){return ee=e,()=>{ee===e&&(ee=null)}}function _s(){return ee}function Ss(e){return[...e.groups.length>0?e.groups.filter(n=>n.expanded).flatMap(n=>n.items):e.workspaces,...e.asideExpanded?e.aside:[]].map(n=>n.id)}function Ms(e,t,n){if(e.length===0)return null;const a=t===null?-1:e.indexOf(t);return a===-1?e[0]:e[a+(n==="clockwise"?1:-1)]??null}let te=null;function As(e){return te=e,()=>{te===e&&(te=null)}}function Is(){return te}function Ts(e){return Mn(e)}function Ua(e){return Sn(e)}function La(e,t){return!e||!t?!1:e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function me(e){if(e.length===0)return[];const t=[];let n=null;for(const a of e){const r=a.timestamp?typeof a.timestamp=="string"?new Date(a.timestamp):a.timestamp:new Date;(!n||!La(n.date,r))&&(n={date:r,label:Ua(r),messages:[]},t.push(n)),n.messages.push(a)}return t}function Es(e){const t=new Map;return e.map(({date:n})=>{const a=`${n.getFullYear()}-${n.getMonth()+1}-${n.getDate()}`,r=t.get(a)??0;return t.set(a,r+1),r===0?a:`${a}#${r}`})}function Cs(e,t){const n=new Map;let a=t?null:void 0;for(const r of e.groups)for(const s of r.messages)a!==void 0&&n.set(s.id,a),s.role==="user"&&!Pn(s)&&(a=s);return n}function Na(e){return`${e.getFullYear()}-${e.getMonth()+1}-${e.getDate()}`}function je(e,t){const n=new Map;return e.map(a=>{const r=`${t}-${Na(a.date)}`,s=(n.get(r)??0)+1;return n.set(r,s),{...a,groupKey:s===1?r:`${r}-${s}`}})}function Ha(e,t){if(e.length===0||t.length===0)return e;const n=new Set(t.map(s=>s.id)),a=new Set(t.map(s=>s.appMessageId).filter(s=>typeof s=="string"&&s.length>0)),r=e.filter(s=>!n.has(s.id)&&!(typeof s.appMessageId=="string"&&s.appMessageId.length>0&&a.has(s.appMessageId)));return r.length===e.length?e:r}function Ds(e,t,n){return e=Ha(e,t),e.length===0?{groups:me(t),detached:!1,hiddenTail:[]}:n?{groups:je(me(e),"h"),detached:!0,hiddenTail:t}:{groups:je(me([...e,...t]),"d"),detached:!1,hiddenTail:[]}}function Rs(e){const{scrollTop:t,threshold:n,fetching:a,exhausted:r,historyCount:s,tailCount:i,tailTruncated:o,totalMessages:l,spacerAbove:c=0}=e;return t>n+c||a||r?!1:s>0||o||l>i+s}const xs=300;function Ps(e){const{fetching:t,chainEvaluationPending:n,visible:a,hideArmed:r}=e;return t||n?a&&!r?"none":"show":a&&!r?"arm-hide":"none"}const qe=24,Fa=320;function Ee(e){return Number.isFinite(e)?Math.min(Fa,Math.max(qe,e)):qe}const Ka=.2,Wa=.12;function ja(e,t,n=Ka){const a=Ee(t);return e===null||!Number.isFinite(e)?a:e+n*(a-e)}function Bs(e,t){const n=Ee(t??Number.NaN);return{above:Math.round(Math.max(0,e.above)*n),below:Math.round(Math.max(0,e.below)*n)}}function Os(e){const{totalMessages:t,residentCount:n,exhausted:a,residentContentHeight:r,currentSpacerHeight:s,viewportHeight:i}=e;let o=e.rowHeightEma;n>0&&r>0&&(o=ja(o,r/n));const l=e.unloadedRows??t-n,d=a||t<=0||n<=0||l<=0||o===null?0:Math.round(l*o),u=Math.abs(d-s);return u===0?{spacerHeight:s,rowHeightEma:o,applied:!1,scrollTopDelta:0}:d===0||s===0||u>s*Wa||i>0&&u>i?{spacerHeight:d,rowHeightEma:o,applied:!0,scrollTopDelta:d-s}:{spacerHeight:s,rowHeightEma:o,applied:!1,scrollTopDelta:0}}const qa=xn,Va=2;function $s(e){const{scrollTop:t,spacerAboveHeight:n,rowHeightEstimate:a,pageSize:r=qa,nearPages:s=Va}=e;if(n<=0||t>=n)return"serial";const i=Ee(a??Number.NaN);return(n-Math.max(0,t))/i>s*r?"seek":"serial"}const yt=200,za=1;function Us(e,t,n=yt){const a=t.timestamp-n;return[...e.filter(r=>r.timestamp>=a),t]}function Ls(e){const{samples:t,viewportHeight:n,windowMs:a=yt,viewportFactor:r=za}=e;if(n<=0||t.length<2)return"gentle";const s=t[t.length-1].timestamp-a,i=t.filter(l=>l.timestamp>=s);if(i.length<2)return"gentle";let o=0;for(let l=1;l<i.length;l+=1)o+=Math.abs(i[l].scrollTop-i[l-1].scrollTop);return o>n*r?"rapid":"gentle"}function Ns(e){const{scrollTop:t,spacerAboveHeight:n,unloadedRowsAbove:a}=e;if(a<=0||n<=0)return 0;const r=Math.min(1,Math.max(0,t/n));return Math.min(a-1,Math.max(0,Math.floor(r*a)))}function Hs(e){const{totalMessages:t,residentCount:n,exhausted:a,startOrdinalEstimate:r,detachedFromTail:s}=e,i=Math.max(0,t-n);if(!s)return{above:a?0:i,below:0};const o=Math.max(0,e.hiddenTailCount??0);if(a)return{above:0,below:i+o};if(r!==null){const c=Math.min(i,Math.max(0,Math.round(r)));return{above:c,below:i-c+o}}const l=Math.min(i,Math.max(0,Math.round(e.holeRowsEstimate??0)));return{above:i-l,below:l+o}}function Fs(e){const{exhausted:t,historyCount:n,tailCount:a,tailTruncated:r,totalMessages:s}=e;return t?!0:n>0?!1:!r&&s<=a}const Ga="intent.drafts.sync",Ja="intent.drafts.changed",Ya=$({id:E(),type:E(),label:E(),description:E().optional(),content:E().optional(),path:E().optional(),imageData:E().optional(),imageMimeType:E().optional(),attachmentId:E().optional(),attachmentMimeType:E().optional(),attachmentSize:ce().optional(),sourcePath:E().optional(),placementStatus:V("failed").optional(),screen:Bn().optional()}),wt=$({text:E(),attachments:On(Ya)}),z={provenance:E().min(1),workspaceId:E().min(1),agentId:E().min(1)},ne={lifetime:E(),revision:ce().int().nonnegative()};$n("kind",[$({...z,kind:V("read")}),$({...z,...ne,kind:V("edit"),origin:E().min(1),sequence:ce().int().positive(),snapshot:wt}),$({...z,...ne,kind:V("flush")}),$({...z,...ne,kind:V("clear"),origin:E().min(1)})]);const bt=$({...z,...ne,origin:E(),sequence:ce().int().nonnegative(),snapshot:wt}),Qa=$({accepted:Un(),draft:bt});function Xa(e,t,n=t){const a=new Map,r=new Set,s=crypto.randomUUID();let i=0,o=!1;const l=()=>{const f=t();if(o||!f)throw new Error("draft-authority-unavailable");return f},c=()=>{const f=n();if(!f||o)throw new Error("draft-authority-unavailable");return()=>{if(o||n()!==f)throw new Error("draft-authority-changed")}},d=(f,k,v)=>{const I=JSON.stringify([f,k,v]);let S=a.get(I);return S||(S={dirty:0},a.set(I,S)),S},u=(f,k)=>{if(o||f.provenance!==t())return;const v=d(f.provenance,f.workspaceId,f.agentId);if(!(v.value?.lifetime===f.lifetime&&v.value.revision>f.revision)&&(v.value=f,k&&v.dirty===0))for(const I of r)I(f)},h=e.subscribe(f=>{const k=bt.safeParse(f);k.success&&u(k.data,!0)}),p=async(f,k)=>{k();const v=Qa.parse(await e.request(f));if(k(),f.provenance!==l()||v.draft.provenance!==f.provenance)throw new Error("draft-authority-changed");if(!v.accepted)throw u(v.draft,!1),new Error("draft-changed-in-another-editor");return v.draft},m=async(f,k)=>{const v=l(),I=c(),S=d(v,f,k);S.tail&&await S.tail;const _=await p({kind:"read",provenance:v,workspaceId:f,agentId:k},I);return u(_,!1),_},y=(f,k,v)=>{const I=l(),S=c(),_=d(I,f,k),B=_.tail??(_.value?Promise.resolve(_.value):p({kind:"read",provenance:I,workspaceId:f,agentId:k},S));_.dirty+=1;const C=B.then(P=>p(v(P),S));return _.tail=C,C.then(P=>{_.dirty-=1,_.tail===C&&(_.tail=void 0),u(P,!0)},()=>{_.dirty-=1,_.tail===C&&(_.tail=void 0)}),C};return{authority:()=>o?null:n(),read:m,async edit(f,k,v,I){const S=++i;return y(k,v,_=>({kind:"edit",provenance:_.provenance,workspaceId:k,agentId:v,lifetime:_.lifetime,revision:_.revision,origin:f,sequence:S,snapshot:I}))},async flush(f,k){const v=l(),I=c(),S=d(v,f,k),_=await(S.tail??(S.value?Promise.resolve(S.value):m(f,k)));await p({kind:"flush",provenance:v,workspaceId:f,agentId:k,lifetime:_.lifetime,revision:_.revision},I)},async clear(f,k){await y(f,k,v=>({kind:"clear",provenance:v.provenance,workspaceId:f,agentId:k,lifetime:v.lifetime,revision:v.revision,origin:s}))},subscribe(f){return r.add(f),()=>{r.delete(f)}},dispose(){o=!0,h(),r.clear(),a.clear()}}}let U=null;async function Ks(e,t,n,a,r){const s=U;if(!s)throw new Error("draft-shared-transport-unavailable");const i=()=>{if(U!==s||s.authority()!==r)throw new Error("draft-authority-changed")};i(),await s.edit(e,t,n,a),i(),await s.flush(t,n),i()}async function Ws(e,t){await Promise.resolve(),U&&await U.flush(e,t)}function js(){if(!et())return null;const e=Xa({request:n=>_n(Ga,n),subscribe:n=>vn(a=>{a.method===Ja&&n(a.params)})},()=>Cn(A.state),()=>Dn(A.state));U=e;const t=e.dispose;return e.dispose=()=>{U===e&&(U=null),t()},e}const kt=new Map;function vt(e,t){return`${e}\0${t}`}function qs(e,t){return kt.get(vt(e,t))}function Vs(e,t,n){kt.set(vt(e,t),n)}const zs=A.createSelector((e,t,n)=>{const a=e.chatPanelUi.byWorkspaceId[t];return a?R(a.userMessageIndexes,n):void 0}),Gs=A.createSelector((e,t,n)=>{const a=e.chatPanelUi.byWorkspaceId[t];return a?R(a.retryAgents,n):void 0});function Za(e){e=Math.max(0,e);const t=Math.floor(e/1e3);if(t<10){const s=e/1e3,i=s.toFixed(1);return i.endsWith(".0")?`${Math.round(s)}s`:`${i}s`}if(t<60)return`${t}s`;const n=Math.floor(t/3600),a=Math.floor(t%3600/60),r=t%60;return n>0?`${n}h ${a}m ${r}s`:`${a}m ${r}s`}function Js(e){return Za(Math.max(1e3,Math.round(e/1e3)*1e3))}const er=new Set(["launch","init","session-create","session-load","prompt"]),tr=new Set(["tool-call","tool-waiting"]);function nr(e){let t=null;for(const n of e)(!t||n.timestamp>=t.timestamp)&&(t=n);return t}function Ys(e){return e&&er.has(e)?"pulse":e&&tr.has(e)?"twist":"bloom"}const _t="stalled";function Qs(e,t){const n=nr(e);return!n||n.phase!==_t||typeof t=="number"&&t>n.timestamp?null:n}function Xs(e){let t=null;for(const n of e)n.phase!==_t&&(!t||n.timestamp>=t.timestamp)&&(t=n);return t}const Ve={get title(){return b.chat_streamingStatus_sessionCorrupted_title()},get message(){return b.chat_streamingStatus_sessionCorrupted_message()}},ar=/^session\/[a-z_]+(?: failed)?:\s*/i;function rr(e){const n=(e.split(`
|
|
12
12
|
`).map(a=>a.trim()).find(Boolean)??"").replace(ar,"");return n.charAt(0).toUpperCase()+n.slice(1)}function Zs(e,t){return e?t===!0?{corrupted:!0,title:Ve.title,message:Ve.message,detail:e}:{corrupted:!1,title:b.chat_streamingStatus_responseFailed_label(),message:rr(e),detail:null}:null}const ei=A.createSelector((e,t)=>R(e.questionUi.consumers,t)),sr=3e4,J=new Map;function ti(e,t){const n=J.get(e);n&&clearTimeout(n.timer);const a=setTimeout(()=>J.delete(e),sr);J.set(e,{value:t,timer:a})}function ni(e){const t=J.get(e);if(t)return clearTimeout(t.timer),J.delete(e),t.value}const St=A.createSelector((e,t,n)=>e.agentWorkers?.byKey[Lt(t,n)]??Ut),ir=A.createSelector((e,t,n)=>{const a=St.select(e,t,n);return a.status==="unsupported"?[]:(a.snapshot?.workers??[]).filter(r=>r.status==="running"||r.status==="unknown")}),ai=A.createSelector((e,t,n)=>{const a=St.select(e,t,n);return a.status==="failed"?!0:a.status!=="ready"||!a.snapshot?!1:a.snapshot.truncated?!0:a.snapshot.support.status!=="supported"&&ir.select(e,t,n).length>0}),or=1e3,Mt={requireViewedAndFocused:!0,requireAssistantTail:!0},Y=new Map,x=new Map;let W=null;function Ce(e){(e===void 0||W===e)&&(W=null)}const cr=200;function lr(e,t){if(x.delete(e),x.set(e,t),x.size>cr){const n=x.keys().next().value;n!==void 0&&x.delete(n)}}function At(e){for(let t=e.length-1;t>=0;t--){const n=e[t];if(!n.isStreaming&&typeof n.id=="string"&&n.id.length>0)return n}return null}function ri(e){return At(e)?.id??null}function si(e){De(e,{requireViewedAndFocused:!0})}function ii(e){De(e,{requireViewedAndFocused:!1})}function oi(e){Ce(),De(e,Mt)}function ci(e){W===e&&(Y.has(e)||(W=null,Re(e,Mt)))}function li(e){for(const t of e)typeof t!="string"||t.length===0||(It(t),Ce(t),Re(t,{requireViewedAndFocused:!1}))}function It(e){const t=Y.get(e);t&&(clearTimeout(t.timer),Y.delete(e))}function De(e,t){It(e),Ce(e);const n=setTimeout(()=>{Y.delete(e),Re(e,t)},or);Y.set(e,{timer:n,gates:t})}let ze=null;function dr(){return ze??=Promise.all([fe(()=>import("./Dnz4szur.js"),__vite__mapDeps([46,21,22,5,23,24,3,8,4,25,15,2,47,48]),import.meta.url),fe(()=>import("./DaqXt9wp.js").then(e=>e.o),__vite__mapDeps([49,45,4,5,21,22,23,24,3,8,25,15,2,13,14,7,9,16,37,36,50,33,42]),import.meta.url)]).then(([e,t])=>({appStore:e.store,appClient:t.appClient})),ze}async function Re(e,t){let n=null;try{const{appStore:a,appClient:r}=await dr(),s=a.state;if(t.requireViewedAndFocused&&(s.unreadTracking?.currentlyViewedAgentId!==e||typeof document<"u"&&!document.hasFocus()))return;const i=s.agentSessions?.byAgentId[e];if(!i)return;const o=typeof i.workspaceId=="string"?i.workspaceId:"";if(o.length===0)return;if(t.requireAssistantTail&&s.chatState?.byAgentId[e]?.initialHistoryPending){W=e;return}const l=At(i.messages??[]);if(!l){t.requireAssistantTail&&(W=e);return}if(t.requireAssistantTail&&l.role!=="assistant")return;const c=l.id;if(x.get(e)===c)return;lr(e,c),n=c,!(await r.agents.markSeen({workspaceId:o,agentId:e,messageId:c})).success&&x.get(e)===n&&x.delete(e)}catch{n!==null&&x.get(e)===n&&x.delete(e)}}const oe=new Map;function Tt(e,t){return`${e}\0${t}`}function di(e,t){return oe.get(Tt(e,t))}function ui(e,t,n){oe.set(Tt(e,t),n)}function mi(e){if(e.length===0)return;const t=new Set(e);for(const n of[...oe.keys()]){const a=n.slice(n.indexOf("\0")+1);t.has(a)&&oe.delete(n)}}export{Ss as $,Nr as A,Qr as B,zr as C,O as D,Ha as E,Jr as F,Ta as G,Ca as H,zn as I,Ws as J,Js as K,Ts as L,or as M,Qs as N,xs as O,di as P,qs as Q,yt as R,Is as S,ms as T,_s as U,qe as V,ps as W,Xs as X,Ys as Y,cs as Z,ls as _,ss as a,Wr as a0,ta as a1,Cs as a2,Kr as a3,Fs as a4,G as a5,qr as a6,jr as a7,$r as a8,Ns as a9,St as aA,ai as aB,us as aC,xr as aD,Pr as aE,Rr as aF,ys as aG,bs as aH,ws as aI,ks as aJ,gt as aK,ei as aL,Gs as aM,zs as aN,ui as aO,Vs as aP,Rs as aQ,Fr as aR,gs as aS,Hs as aT,ti as aU,Ms as aV,xa as aW,ni as aX,na as aY,Hr as aZ,li as aa,ci as ab,si as ac,ii as ad,oi as ae,ri as af,Ps as ag,os as ah,Xr as ai,Nn as aj,Ks as ak,Vr as al,rs as am,Yr as an,Pa as ao,pt as ap,Ur as aq,As as ar,Os as as,vs as at,is as au,Ce as av,ds as aw,Br as ax,Bs as ay,ir as az,we as b,Us as c,ns as d,as as e,Es as f,Lr as g,Ea as h,Or as i,ra as j,aa as k,Ls as l,$s as m,mi as n,hs as o,Ds as p,ts as q,es as r,Gr as s,js as t,Zr as u,Zs as v,fs as w,Ma as x,ge as y,jn as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g_ as O,gG as H,Jj as P,K7 as K,Dd as U,tR as j,uO as q,AJ as N,AK as V,Jh as z,Ji as Q,AL as X}from"./CI4_aI7e.js";import{selectWorkspaceTabOrder as f,selectCurrentWorkspaceTabId as S,selectLastClosedWorkspaceTab as Y}from"./Dq9sK6wY.js";import{i as Z,q as M,b as ee,j as te,l as ae}from"./DQLMO9xD.js";import{g as ne}from"./
|
|
1
|
+
import{g_ as O,gG as H,Jj as P,K7 as K,Dd as U,tR as j,uO as q,AJ as N,AK as V,Jh as z,Ji as Q,AL as X}from"./CI4_aI7e.js";import{selectWorkspaceTabOrder as f,selectCurrentWorkspaceTabId as S,selectLastClosedWorkspaceTab as Y}from"./Dq9sK6wY.js";import{i as Z,q as M,b as ee,j as te,l as ae}from"./DQLMO9xD.js";import{g as ne}from"./MmbRHAVV.js";import{bm as l}from"./51_h0jm2.js";import{z as oe,S as y}from"./rIUowGAi.js";import{B as h,S as C,Q as ce}from"./Bqd7fdCF.js";import{ab as le,a9 as E}from"./CQCytUET.js";import{g as se}from"./DPvT-ATr.js";function A(e,a){const n=f.select(e.state),o=S.select(e.state);if(!o)return null;const c=n.indexOf(o),s=c+(a==="left"?-1:1),p=n[s];return c<0||!p?null:(e.dispatch(j(o,p,a==="left"?"before":"after")),o)}function B(e){const a=S.select(e);return a&&f.select(e).includes(a)?a:null}function m(e,a,n){const o=B(e.state),c=o?`/workspace/${o}`:ne(e.state);return a!==c&&n(c),o}function ie(e,a,n,o){return e.dispatch(O(a)),m(e,n,o),a}function I(e,a){const o=a.match(/^\/workspace\/([^/]+)/)?.[1];return o?o==="new"?null:o:null}function R(e,a,n,o){if(n==="/")return D(e,a==="next"?0:"last",n,o);e.dispatch(a==="next"?z():Q());const c=S.select(e.state);if(!c)return null;const s=`/workspace/${c}`;return n!==s&&o(s),c}function re(e,a,n){const o=I(e,a);return o?ie(e,o,a,n):null}function pe(e,a,n){const o=I(e,a);if(!o)return null;const c=Z.select(e.state,o);if(!c)return null;const s=c.tabs.find(v=>v.id===c.activeTabId),p=c.tabs.length===0&&c.activeTabId===null,g=M.select(e.state,o)>1&&(p||c.tabs.length===1&&s!==void 0&&s.closable!==!1);if((!s||s.closable===!1)&&!g)return null;const T=n??se(o)?.availableCanvasWidth??void 0;return e.dispatch(H(o,void 0,T)),s?.id??c.id}function ue(e,a){const n=e.state.panelLayout.byWorkspaceId[a];return!n||n.restoreStatus==="pending"?!1:ee.select(e.state,a).length===0}function de(e,a,n){B(e.state)||e.dispatch(P(0)),m(e,a,n)}function L(e,a,{navigate:n,closeWindow:o}){return o?(o(),"window"):(m(e,a,n),null)}function be(e,a,n){const o=I(e,a);return o?pe(e,a,n.availableCanvasWidth)!==null?"panel":ue(e,o)?(e.dispatch(O(o)),f.select(e.state).length>0?(de(e,a,n.navigate),"workspace"):L(e,a,n)??"workspace"):null:f.select(e.state).length>0?null:L(e,a,n)}function fe(e,a,n){return e.dispatch(X()),m(e,a,n)}function ke(e,a,n){const o=a.match(/^\/workspace\/([^/]+)/),c=o&&o[1]!=="new"?o[1]:null,s=Y.select(e.state),p=c?ae.select(e.state,c):null;return c&&p&&(!s||p.closedAt>=s.closedAt)?p.kind==="column"?(e.dispatch(N(c)),"column"):(e.dispatch(V(c)),p.kind):s?(fe(e,a,n),"workspace"):null}function _e(e,a){const n=a.match(/^\/workspace\/([^/]+)/),o=n&&n[1]!=="new"?n[1]:null;if(!o)return null;const c=q(o);return e.dispatch(c),te.select(e.state,o)}function D(e,a,n,o){const c=f.select(e.state),s=a==="last"?c.length-1:a;return s<0||s>=c.length?null:(e.dispatch(P(s)),m(e,n,o))}function We({isMac:e,register:a,store:n,getCurrentPath:o,navigate:c,openNewWorkspace:s,getRailMachineIds:p,onCreateAgent:g,onCreateNote:T,onCreateTerminal:v,onCreateBrowser:G,onWorkspaceTabMoved:W,closeWindow:F,resolveBinding:w}){const r=e?{meta:!0}:{ctrl:!0},$=oe("TOGGLE_SIDEBAR",e),k=t=>()=>t(o()),J=t=>()=>{const i=o().match(/^\/workspace\/([^/]+)/);i?.[1]&&i[1]!=="new"&&t(i[1])},u=t=>w?{binding:()=>w(t)}:{},_=t=>w?.(t)??ce(t);a({...u("global.new-space"),...r,key:"n",global:!0,description:l.workspace_shortcuts_newSpace_description(),action:s}),a({...u("panel.toggle-sidebar"),...$,global:!0,description:y.TOGGLE_SIDEBAR.label,action:()=>n.dispatch(K())}),a({...u("navigation.new-tab"),...r,key:"t",global:!0,description:l.workspace_shortcuts_newPanel_description(),action:k(t=>_e(n,t))});for(const[t,i,b,d]of[["workspace.new-agent","a",l.ui_shortcuts_newAgent_label(),g],["workspace.new-note","n",l.layout_panelEmptyState_newItem_tooltip({label:l.layout_panelEmptyState_note_label()}),T],["workspace.new-terminal","t",l.layout_panelEmptyState_newItem_tooltip({label:l.layout_panelEmptyState_terminal_label()}),v],["workspace.new-browser","b",l.layout_panelEmptyState_newItem_tooltip({label:l.layout_panelEmptyState_browser_label()}),G]])d&&a({...u(t),...r,key:i,alt:!0,global:!0,allowInTerminal:!0,description:b,action:J(d)});a({...u("navigation.close-tab"),...r,key:"w",global:!0,description:l.workspace_shortcuts_closePanelTab_description(),action:k(t=>be(n,t,{navigate:c,closeWindow:F}))}),a({...u("navigation.close-space-tab"),...r,key:"w",shift:!0,global:!0,description:l.workspace_shortcuts_closeSpaceTab_description(),action:k(t=>re(n,t,c))}),a({...u("navigation.reopen-tab"),...r,key:"t",shift:!0,global:!0,description:l.workspace_shortcuts_reopenClosedTabOrSpace_description(),action:k(t=>ke(n,t,c))}),a({...u("navigation.move-space-tab-left"),...r,key:"ArrowLeft",alt:!0,shift:!0,global:!0,description:y.MOVE_SPACE_TAB_LEFT.label,action:()=>{const t=A(n,"left");t&&W?.({workspaceId:t,position:f.select(n.state).indexOf(t)+1})}}),a({...u("navigation.move-space-tab-right"),...r,key:"ArrowRight",alt:!0,shift:!0,global:!0,description:y.MOVE_SPACE_TAB_RIGHT.label,action:()=>{const t=A(n,"right");t&&W?.({workspaceId:t,position:f.select(n.state).indexOf(t)+1})}});for(const[t,i]of[["next",!1],["previous",!0]]){a({...u(t==="next"?"global.next-space":"global.previous-space"),key:"Tab",ctrl:!0,shift:i,global:!0,description:t==="next"?l.workspace_shortcuts_nextSpaceTab_description():l.workspace_shortcuts_previousSpaceTab_description(),action:k(d=>R(n,t,d,c))});const b=t==="next"?"global.next-space-alt":"global.previous-space-alt";a({...u(b),...r,key:t==="next"?"}":"{",shift:!0,global:!0,allowInTerminal:!0,preferLocal:!0,enabled:d=>!w||!h(b,d,w,e),description:t==="next"?l.workspace_shortcuts_nextSpaceTab_description():l.workspace_shortcuts_previousSpaceTab_description(),action:k(d=>R(n,t,d,c))})}const x=t=>{t===1?c("/"):D(n,t===9?"last":t-2,o(),c)};for(let t=1;t<=9;t++)a({...r,key:String(t),binding:()=>_("navigation.go-to-device").replace(/([1-8])-9$/,String(t)),global:!0,allowInTerminal:!0,enabled:i=>E.select(n.state)&&!h("navigation.go-to-device",i,_,e),description:l.machineRail_nav_ariaLabel(),action:()=>{const i=p?.()??le.select(n.state).map(d=>d.id),b=i[t===9?i.length-1:t-1];b&&n.dispatch(U(b))}});for(let t=1;t<=9;t++)a({...r,key:String(t),binding:()=>C["navigation.go-to-device"].replace(/([1-8])-9$/,String(t)),global:!0,allowInTerminal:!0,enabled:i=>!E.select(n.state)&&_("navigation.go-to-tab")===C["navigation.go-to-tab"]&&!h("navigation.go-to-device",i,_,e),description:l.ui_shortcuts_goToTab_label(),action:()=>x(t)});for(let t=1;t<=9;t++)a({binding:()=>_("navigation.go-to-tab").replace(/([1-8])-9$/,String(t)),...r,alt:!0,key:String(t),global:!0,allowInTerminal:!0,enabled:i=>!h("navigation.go-to-tab",i,_,e),description:t===1?l.home_navigation_description():t===9?l.workspace_shortcuts_selectLastSpaceTab_description():l.workspace_shortcuts_selectSpaceTab_description({digit:t}),action:()=>x(t)})}export{be as c,We as r};
|