import axios from "axios";
import { mergeProps, useSSRContext } from "vue";
import { ssrRenderAttrs, ssrRenderList, ssrRenderClass, ssrInterpolate, ssrRenderStyle, ssrRenderAttr } from "vue/server-renderer";
import { _ as _export_sfc } from "../entries/pages.mjs";
import "@vue/server-renderer";
import "vue-router";
import "@vueuse/head";
import "vike/server";
/* empty css               */
/* empty css               */
import "pinia";
import "vue-i18n";
/*! src/views/ClientsPage.vue?vue&type=style&index=0&lang.scss [vike:pluginModuleBanner] */
/*! src/views/ClientsPage.vue [vike:pluginModuleBanner] */
const _sfc_main = {
  data() {
    return {
      activeTabId: "",
      tabs: [
        {
          id: "",
          name_en: "All",
          name_ar: "الكل"
        }
      ],
      partners: [],
      loading: false
    };
  },
  methods: {
    changeTab(tab) {
      this.activeTabId = tab.id;
      this.loadPartners(tab);
    },
    async loadPartners(tab) {
      var _a, _b;
      this.loading = true;
      try {
        const response = await axios.get(`https://admin.valueerp.net/api/partners?category_id=${tab.id}`);
        this.tabs = [{ id: "", name_en: "All", name_ar: "الكل" }, ...((_b = (_a = response.data) == null ? void 0 : _a.data) == null ? void 0 : _b.data) || []];
        this.partners = response.data.data.partners;
      } catch (error) {
      } finally {
        this.loading = false;
      }
    }
  },
  async serverPrefetch() {
    await this.loadPartners(this.tabs[0]);
  },
  created() {
    if (typeof window !== "undefined") {
      this.loadPartners(this.tabs[0]);
    }
  }
};
function _sfc_ssrRender(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
  _push(`<div${ssrRenderAttrs(mergeProps({ class: "mt-10 max-w-screen-2xl mx-auto xl:px-32 lg:px-16 md:px-12 sm:px-8 px-6" }, _attrs))}><!-- Loading -->`);
  if ($data.loading) {
    _push(`<div class="fixed inset-0 h-dvh flex items-center justify-center bg-white bg-opacity-90 z-50"><div class="border-4 border-y-ambassador-blue border-x-inherit border-solid w-10 h-10 rounded-full animate-spin"></div></div>`);
  } else {
    _push(`<!---->`);
  }
  _push(`<div class="tabs w-full overflow-x-auto border-b border-solid border-[#90A3BF]"><div class="flex justify-center md:gap-6 gap-2 min-w-fit"><!--[-->`);
  ssrRenderList($data.tabs, (tab, index) => {
    _push(`<div><p class="${ssrRenderClass(`whitespace-nowrap pb-4 md:px-4 px-2 md:text-lg cursor-pointer ${$data.activeTabId === tab.id ? "text-black border-b-4 border-solid border-[#F2994A]" : "text-[#828282]"}`)}">${ssrInterpolate(tab[`name_${_ctx.$i18n.locale}`])}</p></div>`);
  });
  _push(`<!--]--></div></div>`);
  if ($data.partners.length === 0) {
    _push(`<div><p class="text-center mt-20 text-rainmaker">${ssrInterpolate(_ctx.$t("No data available"))}</p></div>`);
  } else {
    _push(`<div class="lg:mt-20 sm:mt-14 mt-8 grid lg:grid-cols-4 sm:grid-cols-3 grid-cols-2 gap-x-2 lg:gap-y-20 sm:gap-y-14 gap-y-8"><!--[-->`);
    ssrRenderList($data.partners, (item, index) => {
      _push(`<div class="sm:p-5 p-3 text-center flex justify-center items-center" style="${ssrRenderStyle({ "box-shadow": "0px 0px 21.79px 0px #0000000A" })}"><img${ssrRenderAttr("src", item.image)} class="m-auto"${ssrRenderAttr("alt", `logo ${item.id}`)}></div>`);
    });
    _push(`<!--]--></div>`);
  }
  _push(`</div>`);
}
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/views/ClientsPage.vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
const ClientsPage = /* @__PURE__ */ _export_sfc(_sfc_main, [["ssrRender", _sfc_ssrRender]]);
export {
  ClientsPage as default
};
