import{d as A,r as f,E as P,a,b as V,e as i,F as _,A as E,f as b,o as l,L as T,c as Y,u as m,X as z,j as F,cr as G}from"./m2W8DxR4.js";import{_ as M}from"./DTaLP_i_.js";import{_ as H,a as O}from"./CioX7pik.js";const X={key:0,dir:"rtl",class:"relative w-full overflow-hidden",role:"region","aria-label":"Video gallery"},D={class:"gallery-container"},Z={class:"relative z-10 h-full w-full overflow-hidden rounded-2xl"},q=["src"],J=["src"],K=["onClick"],Q={class:"relative z-[10] mt-6 flex items-center justify-center gap-6"},W=["disabled"],x={class:"custom-pagination-container"},ee=["onClick"],te=["disabled"],oe=A({__name:"ReelsSlider",props:{projects:{}},setup(n){const s=f(0),d=f([]),c=f(null),y=f(new Map),C=/(?:youtube\.com\/(?:watch\?v=|shorts\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,k=e=>e.includes("youtube")||e.includes("youtu.be"),w=e=>{const t=e.match(C);return t?t[1]:null},I=e=>{const t=w(e);return t?`https://img.youtube.com/vi/${t}/maxresdefault.jpg`:""},N=(e,t=!1)=>{const o=w(e);if(!o)return"";const u=new URLSearchParams({mute:"1",...t&&{autoplay:"1"}});return`https://www.youtube.com/embed/${o}?${u.toString()}`},S=e=>{const t=n.projects.length;if(t===0)return"hidden";const o=(s.value-1+t)%t,u=(s.value+1)%t,p=(s.value-2+t)%t,g=(s.value+2)%t;return e===o?"left":e===s.value?"center":e===u?"right":e===p||e===g?"preload":"hidden"},$=()=>{n.projects.length!==0&&(s.value=(s.value-1+n.projects.length)%n.projects.length)},L=()=>{n.projects.length!==0&&(s.value=(s.value+1)%n.projects.length)},R=e=>{e>=0&&e<n.projects.length&&(s.value=e)},U=(e,t)=>{if(!(t<0)){for(;d.value.length<=t;)d.value.push(null);d.value[t]=e instanceof HTMLVideoElement?e:null}},B=e=>{const t=n.projects[e];if(!t||e<0||e>=n.projects.length){console.warn(`Invalid video index: ${e}`);return}c.value=e;try{if(k(t.url)){const o=N(t.url,!0);y.value.set(e,o)}else{const o=d.value[e];(o==null?void 0:o.tagName)==="VIDEO"&&o.play().catch(u=>{console.warn("Could not play video:",u),c.value=null})}}catch(o){console.error("Error playing video:",o),c.value=null}};return P(s,()=>{if(c.value!==null){const e=d.value[c.value];e instanceof HTMLVideoElement&&e.pause(),c.value=null}}),(e,t)=>{var j;const o=z,u=M,p=H,g=O;return((j=e.projects)==null?void 0:j.length)>0?(l(),a("div",X,[i("div",D,[(l(!0),a(_,null,E(e.projects,(v,r)=>(l(),a("div",{key:r,class:T(["gallery-slide",S(r)])},[i("div",Z,[k(v.url)?(l(),a(_,{key:0},[m(c)!==r?(l(),Y(o,{key:0,src:I(v.url),class:"gallery-media",alt:v.title},null,8,["src","alt"])):(l(),a("iframe",{key:1,class:"gallery-media",src:m(y).get(r)||"",frameborder:"0",allowfullscreen:"",allow:"autoplay; encrypted-media"},null,8,q))],64)):(l(),a("video",{key:1,ref_for:!0,ref:h=>U(h,r),src:v.url,class:"gallery-media",controls:"",muted:"",loop:""},null,8,J)),m(c)!==r?(l(),a("div",{key:2,class:"absolute inset-0 flex cursor-pointer items-center justify-center rounded-2xl bg-[rgba(0,0,0,0.5)]",onClick:h=>B(r)},[b(u,{class:"h-[40px] w-[40px]"})],8,K)):V("",!0)])],2))),128))]),i("div",Q,[i("button",{class:"bg-surface-background border-surface-border rounded-ws-rounded flex-shrink-0 cursor-pointer border p-3",disabled:e.projects.length===0,"aria-label":"Previous video",onClick:$},[b(p,{class:"rtl:scale-x-[-1]"})],8,W),i("div",x,[(l(!0),a(_,null,E(e.projects,(v,r)=>(l(),a("div",{key:`pagination-${r}`,class:T(["pagination-dot",{active:m(s)===r}]),onClick:h=>R(r)},null,10,ee))),128))]),i("button",{class:"bg-surface-background border-surface-border rounded-ws-rounded flex-shrink-0 cursor-pointer border p-3",disabled:e.projects.length===0,"aria-label":"Next video",onClick:L},[b(g,{class:"rtl:scale-x-[-1]"})],8,te)])])):V("",!0)}}}),ne=F(oe,[["__scopeId","data-v-121ff1ce"]]),ae=G("/videos/mobile-application.mp4");export{ae as _,ne as a};
