import { _ as __nuxt_component_0 } from './nuxt-link-8cb59051.mjs';
import { Timeago } from '@vue-layout/timeago';
import { BTable } from 'bootstrap-vue-next';
import { _ as _export_sfc, d as defineNuxtComponent, p as IdentityProviderList, E as EntityDelete, g as useAuthStore, s as storeToRefs, P as PermissionName } from '../server.mjs';
import { i as isRealmResourceWritable } from './utils-8f9455a3.mjs';
import { useSSRContext, resolveComponent, mergeProps, withCtx, createVNode } from 'vue';
import { ssrRenderComponent } from 'vue/server-renderer';
import 'ufo';
import 'ofetch';
import 'hookable';
import 'unctx';
import 'vue-router';
import 'h3';
import '@ebec/http';
import 'hapic';
import '@hapic/oauth2';
import 'rapiq';
import '@hapic/vault';
import '@vue-layout/navigation';
import 'destr';
import 'change-case';
import '@vue-layout/list-controls/core';
import '@vue-layout/form-controls';
import 'smob';
import '@vue-layout/list-controls';
import '@vue-layout/pagination';
import '@ucast/mongo2js';
import '@vuelidate/validators';
import 'ilingo';
import '@vuelidate/core';
import 'nanoid';
import '@unhead/ssr';
import 'unhead';
import '@unhead/shared';
import '@vue-layout/preset-bootstrap-v5';
import '@vue-layout/preset-font-awesome';
import '@vue-layout/countdown';
import 'browser-storage-adapter';
import 'cookie-es';
import 'ohash';
import 'defu';
import '../../nitro/node-server.mjs';
import 'node-fetch-native/polyfill';
import 'node:http';
import 'node:https';
import 'unenv/runtime/fetch/index';
import 'scule';
import 'klona';
import 'unstorage';
import 'radix3';
import 'node:fs';
import 'node:url';
import 'pathe';
import 'http-graceful-shutdown';

const _sfc_main = /* @__PURE__ */ defineNuxtComponent({
  components: {
    BTable,
    IdentityProviderList,
    EntityDelete,
    Timeago
  },
  emits: ["deleted"],
  setup(props, { emit }) {
    const handleDeleted = (e) => {
      emit("deleted", e);
    };
    const store = useAuthStore();
    const { realm, realmManagementId } = storeToRefs(store);
    const query = {
      filter: {
        realm_id: [realmManagementId.value, null]
      }
    };
    const isResourceWritable = (resource) => isRealmResourceWritable(realm.value, resource.realm_id);
    const hasEditPermission = store.has(PermissionName.PROVIDER_EDIT);
    const hasDropPermission = store.has(PermissionName.PROVIDER_DROP);
    const fields = [
      {
        key: "id",
        label: "ID",
        thClass: "text-left",
        tdClass: "text-left"
      },
      {
        key: "name",
        label: "Name",
        thClass: "text-left",
        tdClass: "text-left"
      },
      {
        key: "created_at",
        label: "Created At",
        thClass: "text-center",
        tdClass: "text-center"
      },
      {
        key: "updated_at",
        label: "Updated At",
        thClass: "text-left",
        tdClass: "text-left"
      },
      {
        key: "options",
        label: "",
        tdClass: "text-left"
      }
    ];
    return {
      fields,
      isResourceWritable,
      hasEditPermission,
      hasDropPermission,
      handleDeleted,
      query
    };
  }
}, "$kXQjgiO3wY");
function _sfc_ssrRender(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
  const _component_IdentityProviderList = resolveComponent("IdentityProviderList");
  const _component_BTable = resolveComponent("BTable");
  const _component_Timeago = resolveComponent("Timeago");
  const _component_NuxtLink = __nuxt_component_0;
  const _component_EntityDelete = resolveComponent("EntityDelete");
  _push(ssrRenderComponent(_component_IdentityProviderList, mergeProps({
    "header-title": { icon: "fa-solid fa-list pe-1", content: "Overview" },
    query: _ctx.query,
    onDeleted: _ctx.handleDeleted
  }, _attrs), {
    body: withCtx((props, _push2, _parent2, _scopeId) => {
      if (_push2) {
        _push2(ssrRenderComponent(_component_BTable, {
          items: props.data,
          fields: _ctx.fields,
          busy: props.busy,
          "head-variant": "'dark'",
          outlined: ""
        }, {
          "cell(created_at)": withCtx((data, _push3, _parent3, _scopeId2) => {
            if (_push3) {
              _push3(ssrRenderComponent(_component_Timeago, {
                datetime: data.item.created_at
              }, null, _parent3, _scopeId2));
            } else {
              return [
                createVNode(_component_Timeago, {
                  datetime: data.item.created_at
                }, null, 8, ["datetime"])
              ];
            }
          }),
          "cell(updated_at)": withCtx((data, _push3, _parent3, _scopeId2) => {
            if (_push3) {
              _push3(ssrRenderComponent(_component_Timeago, {
                datetime: data.item.created_at
              }, null, _parent3, _scopeId2));
            } else {
              return [
                createVNode(_component_Timeago, {
                  datetime: data.item.created_at
                }, null, 8, ["datetime"])
              ];
            }
          }),
          "cell(options)": withCtx((data, _push3, _parent3, _scopeId2) => {
            if (_push3) {
              _push3(ssrRenderComponent(_component_NuxtLink, {
                to: "/admin/identity-providers/" + data.item.id,
                class: "btn btn-xs btn-outline-primary me-1",
                disabled: !_ctx.hasEditPermission || !_ctx.isResourceWritable(data.item)
              }, {
                default: withCtx((_, _push4, _parent4, _scopeId3) => {
                  if (_push4) {
                    _push4(`<i class="fa-solid fa-bars"${_scopeId3}></i>`);
                  } else {
                    return [
                      createVNode("i", { class: "fa-solid fa-bars" })
                    ];
                  }
                }),
                _: 2
              }, _parent3, _scopeId2));
              _push3(ssrRenderComponent(_component_EntityDelete, {
                class: "btn btn-xs btn-outline-danger",
                "entity-id": data.item.id,
                "entity-type": "identityProvider",
                "with-text": false,
                disabled: !_ctx.hasDropPermission || !_ctx.isResourceWritable(data.item),
                onDeleted: props.deleted
              }, null, _parent3, _scopeId2));
            } else {
              return [
                createVNode(_component_NuxtLink, {
                  to: "/admin/identity-providers/" + data.item.id,
                  class: "btn btn-xs btn-outline-primary me-1",
                  disabled: !_ctx.hasEditPermission || !_ctx.isResourceWritable(data.item)
                }, {
                  default: withCtx(() => [
                    createVNode("i", { class: "fa-solid fa-bars" })
                  ]),
                  _: 2
                }, 1032, ["to", "disabled"]),
                createVNode(_component_EntityDelete, {
                  class: "btn btn-xs btn-outline-danger",
                  "entity-id": data.item.id,
                  "entity-type": "identityProvider",
                  "with-text": false,
                  disabled: !_ctx.hasDropPermission || !_ctx.isResourceWritable(data.item),
                  onDeleted: props.deleted
                }, null, 8, ["entity-id", "disabled", "onDeleted"])
              ];
            }
          }),
          _: 2
        }, _parent2, _scopeId));
      } else {
        return [
          createVNode(_component_BTable, {
            items: props.data,
            fields: _ctx.fields,
            busy: props.busy,
            "head-variant": "'dark'",
            outlined: ""
          }, {
            "cell(created_at)": withCtx((data) => [
              createVNode(_component_Timeago, {
                datetime: data.item.created_at
              }, null, 8, ["datetime"])
            ]),
            "cell(updated_at)": withCtx((data) => [
              createVNode(_component_Timeago, {
                datetime: data.item.created_at
              }, null, 8, ["datetime"])
            ]),
            "cell(options)": withCtx((data) => [
              createVNode(_component_NuxtLink, {
                to: "/admin/identity-providers/" + data.item.id,
                class: "btn btn-xs btn-outline-primary me-1",
                disabled: !_ctx.hasEditPermission || !_ctx.isResourceWritable(data.item)
              }, {
                default: withCtx(() => [
                  createVNode("i", { class: "fa-solid fa-bars" })
                ]),
                _: 2
              }, 1032, ["to", "disabled"]),
              createVNode(_component_EntityDelete, {
                class: "btn btn-xs btn-outline-danger",
                "entity-id": data.item.id,
                "entity-type": "identityProvider",
                "with-text": false,
                disabled: !_ctx.hasDropPermission || !_ctx.isResourceWritable(data.item),
                onDeleted: props.deleted
              }, null, 8, ["entity-id", "disabled", "onDeleted"])
            ]),
            _: 2
          }, 1032, ["items", "fields", "busy"])
        ];
      }
    }),
    _: 1
  }, _parent));
}
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/admin/identity-providers/index/index.vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["ssrRender", _sfc_ssrRender]]);

export { index as default };
//# sourceMappingURL=index-e6f62936.mjs.map
