import axios from "axios";
import { resolveComponent, reactive, useSSRContext } from "vue";
import { useHead } from "@vueuse/head";
import { T as Testimonials } from "./chunk-CCuwbXH_.js";
import { P as Partners } from "./chunk-CTcGLgUu.js";
import { ssrRenderAttrs, ssrInterpolate, ssrRenderList, ssrRenderClass, ssrRenderAttr, ssrRenderComponent } from "vue/server-renderer";
/* empty css               */
import { _ as _export_sfc } from "../entries/pages.mjs";
/* empty css               */
import "@vue/server-renderer";
import "vue-router";
import "vike/server";
/* empty css               */
/* empty css               */
import "pinia";
import "vue-i18n";
/*! src/views/ModulesPage.vue [vike:pluginModuleBanner] */
const _sfc_main = {
  data() {
    return {
      module: {},
      modulesList: [],
      moduleDescription: {},
      moduleData: [],
      partners: [],
      customersOpinions: [],
      customerOpinionDesc: {},
      advantageDesc: {},
      modulesAdvantages: [],
      loading: false
    };
  },
  setup() {
    const seoState = reactive({
      title: "",
      meta: []
    });
    useHead(seoState);
    return { seoState };
  },
  watch: {
    "$route.params.slug"(val) {
      if (![this.moduleDescription.slug_en, this.moduleDescription.slug_ar].includes(val)) {
        this.loadModules();
      }
    },
    async "$i18n.locale"() {
      await this.$router.push({
        name: "modules-details",
        // 👈 route name
        params: {
          slug: this.moduleDescription[`slug_${this.$i18n.locale}`]
        }
      }).catch(() => {
      });
      this.applySeoFromModule();
    }
  },
  methods: {
    applySeoFromModule() {
      var _a, _b, _c, _d, _e, _f;
      const locale = this.$i18n.locale;
      const titleValue = ((_a = this.module) == null ? void 0 : _a[`meta_title_${locale}`]) || ((_b = this.module) == null ? void 0 : _b[`name_${locale}`]) || "";
      const descriptionSource = ((_c = this.module) == null ? void 0 : _c[`meta_description_${locale}`]) || ((_d = this.module) == null ? void 0 : _d[`content_${locale}`]) || "";
      const description = descriptionSource.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim().slice(0, 160);
      const image = ((_e = this.module) == null ? void 0 : _e.image) || ((_f = this.module) == null ? void 0 : _f.image) || "";
      const title = titleValue ? `${titleValue} | ValuePlus` : "ValuePlus";
      if (!titleValue && !description && !image) return;
      this.seoState.title = title;
      this.seoState.meta = [
        { name: "description", content: description, key: "description" },
        { itemprop: "name", content: title, key: "itemprop:name" },
        { itemprop: "description", content: description, key: "itemprop:description" },
        { itemprop: "image", content: image, key: "itemprop:image" },
        { property: "og:title", content: title, key: "og:title" },
        { property: "og:description", content: description, key: "og:description" },
        { property: "og:image", content: image, key: "og:image" },
        { name: "twitter:title", content: title, key: "twitter:title" },
        { name: "twitter:description", content: description, key: "twitter:description" },
        { name: "twitter:image", content: image, key: "twitter:image" }
      ];
    },
    async loadModules() {
      this.loading = true;
      try {
        const response = await axios.get("https://admin.valueerp.net/api/sectorsModules");
        this.modulesList = response.data.data.modules;
        this.module = this.modulesList.find((element) => [element.slug_en, element.slug_ar].includes(this.$route.params.slug));
        this.applySeoFromModule();
        await this.loadModuleDetails();
      } catch (error) {
      } finally {
      }
    },
    async loadModuleDetails() {
      try {
        const response = await axios.get(`https://admin.valueerp.net/api/module?category_id=${this.module.slug_en}`);
        this.partners = response.data.data.partners;
        this.customersOpinions = response.data.data.module_customers_opinions;
        this.customerOpinionDesc = response.data.data.customer_opinion_desc;
        this.moduleDescription = response.data.data.module_item ? response.data.data.module_item : {};
        this.moduleData = response.data.data.data;
        this.advantageDesc = response.data.data.advantage_desc;
        this.modulesAdvantages = response.data.data.modules_advantages;
      } catch (error) {
      } finally {
        this.loading = false;
      }
    }
  },
  components: {
    Testimonials,
    Partners
  },
  async serverPrefetch() {
    await this.loadModules();
  },
  created() {
    if (typeof window !== "undefined") {
      this.loadModules();
    }
  }
};
function _sfc_ssrRender(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
  const _component_testimonials = resolveComponent("testimonials");
  const _component_partners = resolveComponent("partners");
  _push(`<div${ssrRenderAttrs(_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="-mt-24 bg-no-repeat bg-cover module-cover pt-40 pb-16 mb-14"><div class="max-w-screen-2xl mx-auto xl:px-20 lg:px-16 md:px-12 sm:px-8 px-6"><div class="text-white text-center"><h1 class="font-bold lg:text-4xl sm:text-3xl text-2xl md:mb-6 mb-4">${ssrInterpolate($data.moduleDescription[`title_${_ctx.$i18n.locale}`])}</h1><p class="md:text-lg md:leading-8">${($data.moduleDescription[`content_${_ctx.$i18n.locale}`] ? $data.moduleDescription[`content_${_ctx.$i18n.locale}`].replace(/\t/g, "    ").replace(/\r?\n/g, "<br>") : "") ?? ""}</p></div></div></div>`);
  if ($data.moduleData.length > 0) {
    _push(`<!--[-->`);
    ssrRenderList($data.moduleData, (item, index) => {
      _push(`<div class="mt-6">`);
      if (["left", "right"].includes(item.position_image)) {
        _push(`<div class="${ssrRenderClass(`flex ${item.position_image === "right" ? "sm:flex-row" : "sm:flex-row-reverse"} flex-col-reverse xl:gap-10 gap-6 items-center max-w-screen-2xl mx-auto xl:px-32 lg:px-16 md:px-12 sm:px-8 px-6`)}"><div class="text-legal-eagle sm:w-1/2"><p class="font-bold md:text-2xl sm:text-xl text-lg">${ssrInterpolate(item[`title_${_ctx.$i18n.locale}`])}</p><p class="md:leading-6 lg:mt-6 sm:mt-4 mt-2 md:text-base text-sm">${(item[`content_${_ctx.$i18n.locale}`] ? item[`content_${_ctx.$i18n.locale}`].replace(/\t/g, "    ").replace(/\r?\n/g, "<br>") : "") ?? ""}</p></div><div class="sm:w-1/2 w-3/4 sm:pt-12"><img${ssrRenderAttr("src", item.image)} class="${ssrRenderClass(`w-full object-cover max-h-[400px] max-w-[400px] ${item.position_image === "right" ? "ms-auto" : "me-auto"}`)}"${ssrRenderAttr("alt", item[`title_${_ctx.$i18n.locale}`])}></div></div>`);
      } else if (item.position_image === "center") {
        _push(`<div class="text-legal-eagle text-center sm:mt-14 max-w-screen-2xl mx-auto xl:px-32 lg:px-16 md:px-12 sm:px-8 px-6"><p class="font-bold sm:text-2xl text-xl max-w-2xl m-auto">${ssrInterpolate(item[`title_${_ctx.$i18n.locale}`])}</p><p class="max-w-4xl m-auto md:leading-6 sm:mt-4 mt-2 sm:text-base text-sm">${(item[`content_${_ctx.$i18n.locale}`] ? item[`content_${_ctx.$i18n.locale}`].replace(/\t/g, "    ").replace(/\r?\n/g, "<br>") : "") ?? ""}</p><img${ssrRenderAttr("src", item.image)} class="m-auto object-cover md:mt-8 mt-4 max-h-[400px]"${ssrRenderAttr("alt", item[`title_${_ctx.$i18n.locale}`])}></div>`);
      } else if (item.position_image === "full") {
        _push(`<div class="xl:mt-20 mt-32 max-w-screen-2xl mx-auto xl:px-20 lg:px-16 md:px-12 sm:px-8 px-6"><div class="relative flex xl:flex-row flex-col-reverse xl:items-center md:gap-6 gap-4 bg-no-repeat bg-cover solution-bg rounded-2xl text-white xl:p-12 md:p-8 p-6 w-full"><div class="bg-[#EB5757E5] absolute inset-0 rounded-2xl"></div><div class="relative xl:w-[754px]"><p class="md:font-bold font-semibold md:text-3xl text-2xl">${ssrInterpolate(item[`title_${_ctx.$i18n.locale}`])}</p><p class="xl:mt-6 sm:mt-4 mt-2 xl:leading-9 sm:leading-7 leading-tight">${(item[`content_${_ctx.$i18n.locale}`] ? item[`content_${_ctx.$i18n.locale}`].replace(/\t/g, "    ").replace(/\r?\n/g, "<br>") : "") ?? ""}</p></div><div class="relative shrink-0 xl:w-[550px] w-full xl:h-[300px] sm:h-[200px] h-[150px] object-cover xl:-me-[208px] xl:mt-0 md:-mt-[120px] -mt-[80px] rounded-xl overflow-hidden border-2 border-solid border-white"><img${ssrRenderAttr("src", item.image)} class="w-full h-full object-cover"${ssrRenderAttr("alt", item[`title_${_ctx.$i18n.locale}`])}></div></div></div>`);
      } else {
        _push(`<!---->`);
      }
      _push(`</div>`);
    });
    _push(`<!--]-->`);
  } else {
    _push(`<!---->`);
  }
  if ($data.customersOpinions.length > 0) {
    _push(ssrRenderComponent(_component_testimonials, {
      customerOpinionDesc: $data.customerOpinionDesc,
      customersOpinions: $data.customersOpinions,
      class: "mt-20 max-w-screen-2xl mx-auto xl:px-32 lg:px-16 md:px-12 sm:px-8 px-6"
    }, null, _parent));
  } else {
    _push(`<!---->`);
  }
  if ($data.partners.length > 0) {
    _push(ssrRenderComponent(_component_partners, {
      list: $data.partners,
      title: "Partners of Success",
      class: "mt-20 max-w-screen-2xl mx-auto xl:px-32 lg:px-16 md:px-12 sm:px-8 px-6"
    }, null, _parent));
  } else {
    _push(`<!---->`);
  }
  if ($data.modulesAdvantages.length > 0) {
    _push(`<div class="mt-20 max-w-screen-2xl mx-auto xl:px-32 lg:px-16 md:px-12 sm:px-8 px-6 mb-8"><div class="bg-[#EB5757] rounded-2xl py-8 px-4"><p class="text-center text-white">${($data.advantageDesc[`title_${_ctx.$i18n.locale}`] ? $data.advantageDesc[`title_${_ctx.$i18n.locale}`].replace(/\t/g, "    ").replace(/\r?\n/g, "<br>") : "") ?? ""}</p><div class="mt-8 flex flex-wrap justify-center xl:px-6 px-4 -mb-16"><!--[-->`);
    ssrRenderList($data.modulesAdvantages, (item, index) => {
      _push(`<div class="p-2 md:w-1/4 w-full min-w-[270px] shrink-0"><div class="shadow-[0px_0px_60px_30px_#00000008] bg-white rounded-[10px] p-4 text-center min-h-[320px]"><img${ssrRenderAttr("src", item.image)} width="64" height="64" class="m-auto"${ssrRenderAttr("alt", item[`title_${_ctx.$i18n.locale}`])}><p class="mt-6 leading-tight text-[#6D758F]">${(item[`title_${_ctx.$i18n.locale}`] ? item[`title_${_ctx.$i18n.locale}`].replace(/\t/g, "    ").replace(/\r?\n/g, "<br>") : "") ?? ""}</p></div></div>`);
    });
    _push(`<!--]--></div></div></div>`);
  } else {
    _push(`<!---->`);
  }
  _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/ModulesPage.vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
const ModulesPage = /* @__PURE__ */ _export_sfc(_sfc_main, [["ssrRender", _sfc_ssrRender]]);
export {
  ModulesPage as default
};
