import { _ as __nuxt_component_0 } from './nuxt-link-biyKheoY.mjs';
import { useSSRContext, resolveComponent, mergeProps, withCtx, createVNode } from 'vue';
import { BTable } from 'bootstrap-vue-next';
import { _ as _export_sfc, d as defineNuxtComponent, l as ATitle, a as APagination, k as ASearch, M as ARobots, m as AEntityDelete, i as useAuthStore, s as storeToRefs$1, P as PermissionName } from '../server.mjs';
import { i as isRealmResourceWritable } from './utils-ZPWaiVyc.mjs';
import { ssrRenderComponent } from 'vue/server-renderer';
import '../../nitro/node-server.mjs';
import 'node:http';
import 'node:https';
import 'fs';
import 'path';
import 'node:fs';
import 'node:url';
import 'unhead';
import '@unhead/shared';
import 'vue-router';
import '@ebec/http/core';
import 'hapic';
import '@hapic/oauth2';
import 'rapiq';
import '@hapic/vault';
import '@vuecs/navigation';
import 'change-case';
import '@vuecs/list-controls/core';
import 'smob';
import '@vuecs/list-controls';
import 'ilingo';
import '@vuelidate/validators';
import '@vuelidate/core';
import 'nanoid';
import '@vuecs/form-controls';
import '@vuecs/pagination';
import '@ucast/mongo2js';
import '@vuecs/preset-bootstrap-v5';
import '@vuecs/preset-font-awesome';
import '@vuecs/countdown';
import '@vuecs/timeago';
import '@vuecs/form-controls/core';
import 'browser-storage-adapter';

const _sfc_main = defineNuxtComponent({
  components: {
    ATitle,
    APagination,
    ASearch,
    BTable,
    ARobots,
    AEntityDelete
  },
  emits: ["deleted"],
  setup(props, { emit }) {
    resolveComponent("RobotList");
    const handleDeleted = (e) => {
      emit("deleted", e);
    };
    const store = useAuthStore();
    const { realm, realmManagementId } = storeToRefs$1(store);
    const query = {
      filter: {
        realm_id: [realmManagementId.value, null]
      }
    };
    const isResourceWritable = (resource) => isRealmResourceWritable(realm.value, resource.realm_id);
    const hasEditPermission = store.has(PermissionName.ROBOT_EDIT);
    const hasDropPermission = store.has(PermissionName.ROBOT_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
    };
  }
}, "$BvVi91SvH5");
function _sfc_ssrRender(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
  const _component_ARobots = resolveComponent("ARobots");
  const _component_ATitle = resolveComponent("ATitle");
  const _component_ASearch = resolveComponent("ASearch");
  const _component_APagination = resolveComponent("APagination");
  const _component_BTable = resolveComponent("BTable");
  const _component_VCTimeago = resolveComponent("VCTimeago");
  const _component_NuxtLink = __nuxt_component_0;
  const _component_AEntityDelete = resolveComponent("AEntityDelete");
  _push(ssrRenderComponent(_component_ARobots, mergeProps({
    query: _ctx.query,
    onDeleted: _ctx.handleDeleted
  }, _attrs), {
    header: withCtx((props, _push2, _parent2, _scopeId) => {
      if (_push2) {
        _push2(ssrRenderComponent(_component_ATitle, null, null, _parent2, _scopeId));
        _push2(ssrRenderComponent(_component_ASearch, {
          load: props.load,
          busy: props.busy
        }, null, _parent2, _scopeId));
      } else {
        return [
          createVNode(_component_ATitle),
          createVNode(_component_ASearch, {
            load: props.load,
            busy: props.busy
          }, null, 8, ["load", "busy"])
        ];
      }
    }),
    footer: withCtx((props, _push2, _parent2, _scopeId) => {
      if (_push2) {
        _push2(ssrRenderComponent(_component_APagination, {
          busy: props.busy,
          meta: props.meta,
          load: props.load
        }, null, _parent2, _scopeId));
      } else {
        return [
          createVNode(_component_APagination, {
            busy: props.busy,
            meta: props.meta,
            load: props.load
          }, null, 8, ["busy", "meta", "load"])
        ];
      }
    }),
    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_VCTimeago, {
                datetime: data.item.created_at
              }, null, _parent3, _scopeId2));
            } else {
              return [
                createVNode(_component_VCTimeago, {
                  datetime: data.item.created_at
                }, null, 8, ["datetime"])
              ];
            }
          }),
          "cell(updated_at)": withCtx((data, _push3, _parent3, _scopeId2) => {
            if (_push3) {
              _push3(ssrRenderComponent(_component_VCTimeago, {
                datetime: data.item.created_at
              }, null, _parent3, _scopeId2));
            } else {
              return [
                createVNode(_component_VCTimeago, {
                  datetime: data.item.created_at
                }, null, 8, ["datetime"])
              ];
            }
          }),
          "cell(options)": withCtx((data, _push3, _parent3, _scopeId2) => {
            if (_push3) {
              _push3(ssrRenderComponent(_component_NuxtLink, {
                to: "/admin/robots/" + 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_AEntityDelete, {
                class: "btn btn-xs btn-outline-danger",
                "entity-id": data.item.id,
                "entity-type": "robot",
                "with-text": false,
                disabled: !_ctx.hasDropPermission || !_ctx.isResourceWritable(data.item),
                onDeleted: props.deleted
              }, null, _parent3, _scopeId2));
            } else {
              return [
                createVNode(_component_NuxtLink, {
                  to: "/admin/robots/" + 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_AEntityDelete, {
                  class: "btn btn-xs btn-outline-danger",
                  "entity-id": data.item.id,
                  "entity-type": "robot",
                  "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_VCTimeago, {
                datetime: data.item.created_at
              }, null, 8, ["datetime"])
            ]),
            "cell(updated_at)": withCtx((data) => [
              createVNode(_component_VCTimeago, {
                datetime: data.item.created_at
              }, null, 8, ["datetime"])
            ]),
            "cell(options)": withCtx((data) => [
              createVNode(_component_NuxtLink, {
                to: "/admin/robots/" + 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_AEntityDelete, {
                class: "btn btn-xs btn-outline-danger",
                "entity-id": data.item.id,
                "entity-type": "robot",
                "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/robots/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-UZ5Qizko.mjs.map
