import { useSSRContext, ref, withAsyncContext, watch, mergeProps, unref } from 'vue';
import { ssrRenderAttrs, ssrInterpolate, ssrRenderList, ssrRenderClass } from 'vue/server-renderer';
import { u as useI18n, b as useNuxtApp, d as useLazyAsyncData, f as useRuntimeConfig } from './server.mjs';

const _sfc_main = {
  __name: "StaticPages",
  __ssrInlineRender: true,
  props: {
    endPoint: {
      required: true
    },
    mainTitle: {
      required: true
    }
  },
  async setup(__props) {
    let __temp, __restore;
    const config = useRuntimeConfig();
    const { locale } = useI18n();
    const content = ref(null);
    const title = ref(null);
    const activeBtn = ref(null);
    const props = __props;
    function activeButton(item) {
      activeBtn.value = item.id;
      content.value = item.description;
      title.value = item.type;
    }
    const axios = useNuxtApp().$axios;
    const { data: pageData, error, pending } = ([__temp, __restore] = withAsyncContext(() => useLazyAsyncData(
      `${props.endPoint}`,
      () => axios.get(`${props.endPoint}`, {
        baseURL: config.public.baseURL,
        headers: {
          "Accept-Language": locale.value
        }
      }).then((res) => res.data.data).catch((err) => err)
    )), __temp = await __temp, __restore(), __temp);
    watch(
      () => pageData.value,
      () => {
        if (pageData.value && pageData.value.length > 0) {
          activeButton(pageData.value[0]);
        }
      },
      {
        immediate: true,
        deep: true
      }
    );
    return (_ctx, _push, _parent, _attrs) => {
      var _a;
      _push(`<div${ssrRenderAttrs(mergeProps({ class: "container" }, _attrs))}><h1 class="text-3xl leading-[2.2rem] md:text-5xl font-extrabold mb-3 md:leading-[3.5rem] py-8 capitalize">${ssrInterpolate(__props.mainTitle)}</h1><div class="grid lg:grid-cols-3 grid-cols-1 gap-8"><div class="border rounded-xl col-span-1 px-8 py-8 h-fit mb-8"><div class="space-y-4"><!--[-->`);
      ssrRenderList(unref(pageData), (item) => {
        _push(`<div><button role="button" class="${ssrRenderClass([{
          "text-primary font-bold": unref(activeBtn) === item.id,
          "text-[#A3A3A3]": unref(activeBtn) !== item.id
        }, "text-start"])}">${ssrInterpolate(item.type)}</button></div>`);
      });
      _push(`<!--]--></div></div><div class="col-span-2 space-y-4 my-5"><h2 class="text-2xl font-bold">${ssrInterpolate(unref(title))}</h2><div class="staticPageDescription">${(_a = unref(content)) != null ? _a : ""}</div></div></div></div>`);
    };
  }
};
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/staticPages/StaticPages.vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};

export { _sfc_main as _ };
//# sourceMappingURL=StaticPages-Bo-YFJjx.mjs.map
