function d(i){const l=i.shellOrigin;let p=0;const n=new Map;addEventListener("message",r=>{if(r.source!==parent||r.origin!==l)return;const e=r.data;if(!e||e.__frame_cap_r!==!0)return;const t=typeof e.id=="string"?e.id:null;if(!t)return;const s=n.get(t);s&&(n.delete(t),clearTimeout(s.timer),e.error!=null?s.reject(e.error):s.resolve(e.result))});const u=(r,e)=>new Promise((t,s)=>{const o="s"+ ++p,c=setTimeout(()=>{n.delete(o),s({code:"upstream_error",message:"no reply from shell"})},13e4);n.set(o,{resolve:t,reject:s,timer:c}),parent.postMessage({__frame_cap:!0,cap:"self",id:o,method:r,args:e},l)}),a=i.pipe("self");i.mount("self",{publish:a.wrap("publish",r=>u("publish",[r]))})}export{d as install};
