import{bK as q,H as B,d as E,a as R,u as $,e as m,r as v,R as A,s as H,f as i,aG as N,x as h,bL as Y,g as s,h as a,i as b,A as g,v as D,o as c,a4 as z,_ as K}from"./BxiWQxwE.js";import M from"./BA68jryP.js";import{s as F}from"./B8cvSguG.js";const G=()=>({youtubeCookie:q(`${B}-youtube-accepted`,{default:()=>!1,maxAge:86400})}),U={class:"youtube"},X=["aria-label"],j={class:"theplayer"},J={key:0,class:"placeholder"},O=["src"],Q=["aria-label"],W={class:"icon"},Z={key:0},ee=["innerHTML"],te=E({__name:"youtube",props:{image:{type:String,required:!0},url:{type:String,required:!0},title:{type:String,required:!1,default:""},popup:{type:Boolean,required:!1,default:!1},lightbox:{type:Boolean,required:!1,default:!0}},setup(n){const{youtubeCookie:p}=G(),{$gtm:x,$messages:d}=R(),{path:k}=$(),r=n,w=m(()=>{const o=/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/.exec(r.url);let t=null;return o&&o[2].length===11&&(t=o[2]),t!==null?t:null}),C=e=>{if(/^\d+$/.test(e))return parseInt(e,10);const t=/(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?/.exec(e);if(!t)return 0;const y=parseInt(t[1]||"0",10),T=parseInt(t[2]||"0",10),L=parseInt(t[3]||"0",10);return y*3600+T*60+L},I=m(()=>{const o=new URLSearchParams(r.url.split("?")[1]).get("t");return o?C(o):0}),l=v(),u=v(!1),_=v(null),V=m(()=>p.value?[{src:"https://www.youtube.com/iframe_api"}]:[]);A({script:V});const f=e=>{u.value=!0,e?e.target.playVideo():l.value&&l.value.playVideo()},P=()=>{if(p.value=!0,l.value){f();return}const e=F(()=>{!(YT!=null&&YT.Player)||!_.value||(clearInterval(e),l.value=new YT.Player(_.value,{width:"100%",height:"100%",videoId:w.value,playerVars:{playsinline:1,rel:0,start:I.value},events:{onReady:f}}))},100);x("show_video",{video_location:k,video_content:r.title,video_platform:"youtube"})},S=()=>{var e;u.value=!1,(e=l.value)==null||e.pauseVideo()};return H(u,e=>{r.lightbox||(e&&r.popup?document.body.classList.add("noscroll"):document.body.classList.remove("noscroll"))}),(e,o)=>{const t=z,y=M;return c(),i("div",U,[N(a("div",{class:g(["player-container",{popup:n.popup}])},[n.popup?(c(),i("button",{key:0,"aria-label":s(d)("aria.close"),type:"button",class:"close",onClick:S},[b(t)],8,X)):h("",!0),a("div",j,[a("div",{ref_key:"player",ref:_,class:"player"},null,512)])],2),[[Y,s(u)]]),s(u)?h("",!0):(c(),i("div",J,[a("img",{src:n.image,loading:"lazy",alt:"Youtube Player"},null,8,O),a("button",{type:"button",class:g(["overlay",{youtubeCookie:s(p)}]),"aria-label":s(d)("aria.playVideo"),onClick:P},[a("div",W,[b(y)]),s(p)?(c(),i("p",Z,D(s(d)("video.play")),1)):(c(),i("p",{key:1,innerHTML:s(d)("video.description")},null,8,ee))],10,Q)]))])}}}),ne=K(te,[["__scopeId","data-v-b991365d"]]);export{ne as default};
