import{s as e}from"./chunk-Bj-mKKzh.js";import"./src-BOCweS1p.js";import{n as t,t as n}from"./jsx-runtime-CiQ1k8xo.js";import"./react-dom-CvzHKZGB.js";import{I as r,lt as i}from"./vscode-api-DjORcpSo.js";import"./persisted-signal-CweW-bgN.js";import{n as a}from"./window-zoom-context-CSPQZGcc.js";import"./route-scope-CLteRG86.js";import"./setting-storage-CwKZnsvR.js";import"./reduced-motion-preference-Bd5_3c7y.js";import{a as o,i as s}from"./app-shell-state-Dskh7Hih.js";import{n as c,s as l}from"./app-shell-tab-controller-cnh2C4j9.js";import{t as u}from"./browser-sidebar-manager-BtbIv4P0.js";import{h as d,p as f,u as p}from"./browser-sidebar-open-source-_kvO2A9r.js";import{t as m}from"./browser-sidebar-webview-BiStOkKQ.js";var h=i(),g=e(t(),1),_=n();function v(e){let t=(0,h.c)(9),{conversationId:n}=e,i=r(c.activeTab$),a=r(c.tabs$),d=r(o),f=r(s),p,m;t[0]===f?(p=t[1],m=t[2]):(p=e=>f.on(`change`,e),m=()=>f.get(),t[0]=f,t[1]=p,t[2]=m);let v=(0,g.useSyncExternalStore)(p,m,x),w=l(i,n),T=w!=null&&(d||v>0),E;t[3]===n?E=t[4]:(E=()=>u.getBrowserUseBrowserTabIdsKey(n),t[3]=n,t[4]=E),(0,g.useSyncExternalStore)(b,E,y);let D=C({activeBrowserTabId:w,conversationId:n,hasMountedBrowserPanel:T,rightPanelTabs:a});if(D.length===0)return null;let O;t[5]===n?O=t[6]:(O=e=>(0,_.jsx)(S,{browserTabId:e,conversationId:n},e),t[5]=n,t[6]=O);let k=D.map(O),A;return t[7]===k?A=t[8]:(A=(0,_.jsx)(_.Fragment,{children:k}),t[7]=k,t[8]=A),A}function y(){return``}function b(e){return u.subscribe(e)}function x(){return 0}function S(e){let t=(0,h.c)(10),{browserTabId:n,conversationId:r}=e,i=a(),o=(0,g.useRef)(null),s;t[0]!==n||t[1]!==r?(s=T(r,n),t[0]=n,t[1]=r,t[2]=s):s=t[2];let c=s;if(c==null||!w(r,n))return null;let l;return t[3]!==n||t[4]!==r||t[5]!==c.adoptedWebContentsId||t[6]!==c.adoptionLease||t[7]!==c.initialUrl||t[8]!==i?(l=(0,_.jsx)(m,{adoptionLease:c.adoptionLease,adoptedWebContentsId:c.adoptedWebContentsId,bounds:null,browserTabId:n,conversationId:r,initialUrl:c.initialUrl,isVisible:!1,scale:1,shouldBootstrapWhenHidden:!0,shouldPaint:!1,webviewRef:o,windowZoom:i}),t[3]=n,t[4]=r,t[5]=c.adoptedWebContentsId,t[6]=c.adoptionLease,t[7]=c.initialUrl,t[8]=i,t[9]=l):l=t[9],l}function C({activeBrowserTabId:e,conversationId:t,hasMountedBrowserPanel:n,rightPanelTabs:r}){return r.flatMap(r=>{let i=l(r,t)??null;return i==null||u.isBrowserUseTab(t,i)||n&&i===e||!w(t,i)?[]:[i]})}function w(e,t){return u.isBrowserUseTab(e,t)?!1:T(e,t)!=null}function T(e,t){let n=f(e,t),r=d(e,t),i=p(e,t);return n==null&&(r==null||i==null)?null:{adoptedWebContentsId:i,adoptionLease:r,initialUrl:n??`about:blank`}}export{v as HiddenBackgroundBrowserWebviewHost};
//# sourceMappingURL=browser-sidebar-hidden-background-webview-host-CgecZTTz.js.map