import{t as P,Z as g,aJ as E,ac as F,a8 as O,z as c,B as d,H as U,aK as B,E as S,F as D,I as w,C as M,aY as N,L as j,W as x,G as z,O as T,o as A,P as $,R as V,aF as G}from"./en-DOjYsYaJ.js";const H=["src"],K=["src"],Z=P({__name:"share-preview",props:{opts:{}},emits:["selected"],setup(v,{emit:_}){const h=_,I=v,{srcId:f,name:u,thumbnailURL:m,stream:y,display_id:R,appIconURL:o,initiallySelected:b}=I.opts,i=g(b),r=E(),p=g(!1);return F(async()=>{r.value.srcObject=await y,p.value=!0}),O(async()=>{i.value||(await y).getTracks().forEach(t=>t.stop())}),(t,e)=>(c(),d("div",null,[U(S("video",{class:D(t.$style.videoPreview),ref_key:"videoTag",ref:r,playsinline:"",autoplay:"",muted:""},null,2),[[B,!!p.value]]),U(S("img",{src:w(m)},null,8,H),[[B,!p.value]]),e[2]||(e[2]=S("br",null,null,-1)),M(w(N),{modelValue:i.value,"onUpdate:modelValue":e[0]||(e[0]=s=>i.value=s),size:"24",onChange:e[1]||(e[1]=s=>h("selected",s))},null,8,["modelValue"]),e[3]||(e[3]=S("br",null,null,-1)),w(o)?(c(),d("img",{key:0,class:D(t.$style.appIcon),src:w(o)},null,10,K)):j("",!0),x(" "+z(w(u)),1)]))}}),J="_appIcon_10wa8_1",W="_videoPreview_10wa8_6",Y={appIcon:J,videoPreview:W},q={$style:Y},k=T(Z,[["__cssModules",q]]),Q=P({__name:"screen-share-choice-dialog",props:{intiallyShared:{}},emits:["select"],setup(v,{emit:_}){function h(t){return!!v.intiallyShared.find(e=>e.srcId===t)}const I=_,f=g(),u=g(),m=new Map;function y(t){const e=G();return m.set(t,e),e.promise}async function R(){await w3n.mediaDevices.setSelectDisplayMediaForCaptureHandler(b),o=void 0,await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0}).catch(e=>console.error("Error on the start of collection",e));async function t({srcId:e,initiallySelected:s}){var a;if(s){const{stream:n}=v.intiallyShared.find(l=>l.srcId===e);(a=m.get(e))==null||a.resolve(n)}else{o=e;const n=m.get(o);n&&(m.delete(o),await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0}).then(l=>{n.resolve(l)},l=>n.reject(l))),o=void 0}}if(f.value)for(const e of f.value)await t(e);if(u.value)for(const e of u.value)await t(e)}let o;async function b(t){var e,s;if(o===void 0){f.value=(e=t.screens)==null?void 0:e.map(a=>{const{id:n,name:l,display_id:C}=a,L=i(a.thumbnail);return{srcId:n,name:l,display_id:C,thumbnailURL:L,initiallySelected:h(n),stream:y(n)}}),u.value=(s=t.windows)==null?void 0:s.map(a=>{const{id:n,name:l}=a,C=i(a.thumbnail),L=i(a.appIcon);return{srcId:n,name:l,thumbnailURL:C,appIconURL:L,initiallySelected:h(n),stream:y(n)}});return}else return o}function i(t){if(!t)return;const e=new Blob([t],{type:"image/bmp"});return URL.createObjectURL(e)}A(()=>{R()}),O(()=>{});const r=v.intiallyShared.concat();async function p(t,e){if(e){const s=await t.stream;r.push({srcId:t.srcId,stream:s,type:t.display_id?"screen":"window"})}else{const s=r.findIndex(({stream:{id:a}})=>a===t.srcId);r.splice(s,1)}I("select",r)}return(t,e)=>(c(),d("div",{class:D(t.$style.dialog)},[(c(!0),d($,null,V(f.value,s=>(c(),d("div",null,[M(k,{opts:s,onSelected:a=>p(s,a)},null,8,["opts","onSelected"])]))),256)),(c(!0),d($,null,V(u.value,s=>(c(),d("div",null,[M(k,{opts:s,onSelected:a=>p(s,a)},null,8,["opts","onSelected"])]))),256))],2))}}),X="_dialog_6n6l2_1",ee={dialog:X},te={$style:ee},ae=T(Q,[["__cssModules",te]]);export{ae as default};
