import { a as _export_sfc, g as _sfc_main$d } from './server.mjs';
import { _ as __nuxt_component_1 } from './VideoButton-B4IDmAbs.mjs';
import { _ as __nuxt_component_2$1, a as __nuxt_component_1$1 } from './GradientFullArrowRight-B3gaunpf.mjs';
import { defineComponent, computed, ref, unref, mergeProps, useSSRContext } from 'vue';
import { ssrRenderAttrs, ssrRenderList, ssrRenderClass, ssrRenderComponent, ssrRenderAttr, ssrIncludeBooleanAttr } from 'vue/server-renderer';
import '../_/nitro.mjs';
import 'node:http';
import 'node:https';
import 'node:events';
import 'node:buffer';
import 'nitropack/dist/runtime/plugin';
import 'packrup';
import 'consola';
import 'node:fs';
import 'node:url';
import '@iconify/utils';
import 'node:crypto';
import 'ipx';
import 'node:path';
import 'pinia';
import '@pinia/colada';
import 'vue-router';
import '@unhead/schema-org/vue';
import 'deep-pick-omit';
import '@iconify/vue';
import '../routes/renderer.mjs';
import 'vue-bundle-renderer/runtime';
import 'unhead/server';
import 'devalue';
import 'unhead/plugins';
import 'unhead/utils';

const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "SocialVideosSlider",
  __ssrInlineRender: true,
  props: {
    projects: {}
  },
  setup(__props) {
    const props = __props;
    const projects = computed(
      () => Array.isArray(props.projects) ? props.projects : props.projects.value
    );
    const currentIndex = ref(0);
    ref([]);
    const playingVideoIndex = ref(null);
    const youtubeEmbedUrls = ref(/* @__PURE__ */ new Map());
    const YOUTUBE_REGEX = /(?:youtube\.com\/(?:.*v=|embed\/|shorts\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/;
    const isYouTubeVideo = (url) => {
      return url.includes("youtube") || url.includes("youtu.be");
    };
    const getYouTubeVideoId = (url) => {
      const match = url.match(YOUTUBE_REGEX);
      return match ? match[1] : null;
    };
    const getYouTubeThumbnail = (url) => {
      const videoId = getYouTubeVideoId(url);
      return videoId ? `https://img.youtube.com/vi/${videoId}/maxresdefault.jpg` : "";
    };
    const getSlidePosition = (index) => {
      const total = projects.value.length;
      if (total === 0) return "hidden";
      const prev = (currentIndex.value - 1 + total) % total;
      const next = (currentIndex.value + 1) % total;
      const secondPrev = (currentIndex.value - 2 + total) % total;
      const secondNext = (currentIndex.value + 2) % total;
      if (index === prev) return "left";
      if (index === currentIndex.value) return "center";
      if (index === next) return "right";
      if (index === secondPrev || index === secondNext) return "preload";
      return "hidden";
    };
    return (_ctx, _push, _parent, _attrs) => {
      const _component_NuxtImg = _sfc_main$d;
      const _component_SvgVideoButton = __nuxt_component_1;
      const _component_SvgGradientFullArrowLeft = __nuxt_component_2$1;
      const _component_SvgGradientFullArrowRight = __nuxt_component_1$1;
      if (unref(projects).length > 0) {
        _push(`<div${ssrRenderAttrs(mergeProps({
          dir: "rtl",
          class: "relative w-full overflow-hidden",
          role: "region",
          "aria-label": "Video gallery"
        }, _attrs))} data-v-ee987975><div class="gallery-container" data-v-ee987975><!--[-->`);
        ssrRenderList(unref(projects), (project, index) => {
          _push(`<div class="${ssrRenderClass(["gallery-slide", getSlidePosition(index)])}" data-v-ee987975><div class="relative z-10 h-full w-full overflow-hidden rounded-2xl" data-v-ee987975>`);
          if (isYouTubeVideo(project.video_url)) {
            _push(`<!--[-->`);
            if (unref(playingVideoIndex) !== index) {
              _push(ssrRenderComponent(_component_NuxtImg, {
                src: getYouTubeThumbnail(project.video_url),
                class: "gallery-media",
                alt: project.title
              }, null, _parent));
            } else {
              _push(`<iframe class="gallery-media aspect-video"${ssrRenderAttr("src", unref(youtubeEmbedUrls).get(index) || "")} frameborder="0" allowfullscreen allow="autoplay; encrypted-media" data-v-ee987975></iframe>`);
            }
            _push(`<!--]-->`);
          } else {
            _push(`<video${ssrRenderAttr("src", project.video_url)} class="gallery-media aspect-video" controls muted loop data-v-ee987975></video>`);
          }
          if (unref(playingVideoIndex) !== index) {
            _push(`<div class="absolute inset-0 flex cursor-pointer items-center justify-center rounded-2xl bg-[rgba(0,0,0,0.5)]" data-v-ee987975>`);
            _push(ssrRenderComponent(_component_SvgVideoButton, { class: "h-[40px] w-[40px]" }, null, _parent));
            _push(`</div>`);
          } else {
            _push(`<!---->`);
          }
          _push(`</div></div>`);
        });
        _push(`<!--]--></div><div class="relative z-[10] mt-6 flex items-center justify-center gap-6" data-v-ee987975><button class="bg-surface-background border-surface-border rounded-ws-rounded flex-shrink-0 cursor-pointer border p-3"${ssrIncludeBooleanAttr(unref(projects).length === 0) ? " disabled" : ""} aria-label="Previous video" data-v-ee987975>`);
        _push(ssrRenderComponent(_component_SvgGradientFullArrowLeft, { class: "rtl:scale-x-[-1]" }, null, _parent));
        _push(`</button><div class="custom-pagination-container" data-v-ee987975><!--[-->`);
        ssrRenderList(unref(projects), (project, index) => {
          _push(`<div class="${ssrRenderClass([{ active: unref(currentIndex) === index }, "pagination-dot"])}" data-v-ee987975></div>`);
        });
        _push(`<!--]--></div><button class="bg-surface-background border-surface-border rounded-ws-rounded flex-shrink-0 cursor-pointer border p-3"${ssrIncludeBooleanAttr(unref(projects).length === 0) ? " disabled" : ""} aria-label="Next video" data-v-ee987975>`);
        _push(ssrRenderComponent(_component_SvgGradientFullArrowRight, { class: "rtl:scale-x-[-1]" }, null, _parent));
        _push(`</button></div></div>`);
      } else {
        _push(`<!---->`);
      }
    };
  }
});
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/global/SocialVideosSlider.vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
const __nuxt_component_2 = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-ee987975"]]);

export { __nuxt_component_2 as default };
//# sourceMappingURL=SocialVideosSlider-DQncfJv-.mjs.map
