function e(){let e=null,t=null,n=new Set,r=!1,i=null;function a(){for(let e of n)e()}function o(){e!==null&&(e=null,a())}return{install({bridge:n}){if(n)return r?i??void 0:(r=!0,t=n,i=n.mcpWiring.onShow(t=>{e=t,a()}),n.mcpWiring.signalReady(),()=>{i?.(),i=null,r=!1,t=null,o()})},getSnapshot(){return e},subscribe(e){return n.add(e),()=>{n.delete(e)}},async confirm(e){let n=t;if(!n)return{ok:!1,error:`Not attached to desktop bridge`};try{let t=await n.mcpWiring.confirm(e);return t.ok&&o(),t}catch(e){return{ok:!1,error:e instanceof Error?e.message:`Unknown error`}}},async skip(){let e=t;if(!e)return{ok:!1,error:`Not attached to desktop bridge`};try{let t=await e.mcpWiring.skip();return t.ok&&o(),t}catch(e){return{ok:!1,error:e instanceof Error?e.message:`Unknown error`}}},dismiss(){o()}}}var t=e();function n(e){return t.install(e)}export{t as n,n as t};