import { bK as qe, bL as Te, az as he, aA as Ce, d as T, bM as Jt, H as Ee, bN as Yt, m as He, p as _e, ah as we, h as Y, bO as Ne, bP as Le, n as Se, l as Ke, o as ue, a5 as bt, aq as Ue, _ as Qt, A as Pt, ag as Xt, af as Gt, ap as Ve, j as ee, s as yt, i as Z, ai as We, aj as Je, ak as Ye, al as Qe, ae as ge, aW as Xe, a8 as Ge, a9 as Ze, aa as et, ab as tt, am as at, an as ot, ac as st, ad as nt, bQ as lt, bR as rt, bS as it, a6 as St, bT as Re, aD as Zt, aB as ut, aG as ht, b8 as Ct, b9 as ea, g as Dt, aX as ta, bI as aa, B as oa, D as sa, aS as na, bU as la, k as ra, bV as ia, bW as ze, aU as ua, aV as ca, aK as da, F as ma, a_ as fa, ao as va, a1 as pa, bX as ga, q as ba, x as ya } from "./AFormRemoteAutocomplete.vue_vue_type_script_setup_true_lang-BEC0fw4c.mjs";
import { ay as ds, bY as ms, bZ as fs, av as vs, aw as ps, ax as gs, aC as bs, b7 as ys, at as hs, au as Cs } from "./AFormRemoteAutocomplete.vue_vue_type_script_setup_true_lang-BEC0fw4c.mjs";
import { defineComponent as ae, inject as N, computed as U, nextTick as de, ref as V, watch as se, resolveComponent as be, createElementBlock as I, openBlock as C, Fragment as te, createBlock as E, createCommentVNode as W, withModifiers as M, unref as _, withCtx as f, createVNode as u, mergeProps as ct, renderSlot as K, createTextVNode as j, toDisplayString as D, getCurrentInstance as ha, normalizeClass as Be, renderList as me, createElementVNode as z, useTemplateRef as $t, createSlots as Ca, mergeModels as fe, useModel as Ae, onMounted as xt, provide as kt, resolveDynamicComponent as ka, withDirectives as Et, vShow as Vt, toRaw as _t } from "vue";
import { useI18n as le } from "vue-i18n";
import { VCard as dt, VCardText as It, VCardActions as Ut } from "vuetify/components/VCard";
import { VDialog as mt } from "vuetify/components/VDialog";
import { VSpacer as ft, VRow as De, VCol as pe } from "vuetify/components/VGrid";
import { VListItem as vt, VList as Rt, VListItemTitle as Ot } from "vuetify/components/VList";
import { VSelect as _a } from "vuetify/components/VSelect";
import { VTextarea as wa } from "vuetify/components/VTextarea";
import { VAutocomplete as Aa } from "vuetify/components/VAutocomplete";
import { VBtn as G } from "vuetify/components/VBtn";
import { VIcon as ye } from "vuetify/components/VIcon";
import { VTooltip as Fe } from "vuetify/components/VTooltip";
import { VChip as wt } from "vuetify/components/VChip";
import { defineStore as Fa } from "pinia";
import pt from "axios";
import At from "@vuelidate/core";
import { VProgressCircular as Ta } from "vuetify/components/VProgressCircular";
import { VTabs as Ba, VTab as Ft } from "vuetify/components/VTabs";
import { useResizeObserver as Pa, watchThrottled as Sa, useDebounceFn as Da } from "@vueuse/core";
import { VMenu as jt } from "vuetify/components/VMenu";
import { VForm as $a } from "vuetify/components/VForm";
import { VBtnToggle as xa } from "vuetify/components/VBtnToggle";
import { VToolbar as Ea } from "vuetify/components/VToolbar";
import { Intersect as Va } from "vuetify/directives";
const Ia = /* @__PURE__ */ ae({
  __name: "AFilterTimeInterval",
  props: {
    nameFrom: {},
    nameUntil: {},
    allowed: { default: void 0 },
    placeholder: { default: void 0 },
    dataCy: { default: "filter-time-interval" }
  },
  emits: ["change"],
  setup(b, { emit: d }) {
    const t = b, o = d, v = N(qe), c = N(Te), n = N(he), e = N(Ce);
    if (T(v) || T(c) || T(n) || // eslint-disable-next-line vue/no-setup-props-reactivity-loss
    T(n.fields[t.nameFrom]) || // eslint-disable-next-line vue/no-setup-props-reactivity-loss
    T(n.fields[t.nameUntil]) || T(e) || // eslint-disable-next-line vue/no-setup-props-reactivity-loss
    T(e[t.nameFrom]) || // eslint-disable-next-line vue/no-setup-props-reactivity-loss
    T(e[t.nameUntil]))
      throw new Error("Incorrect provide/inject config.");
    const p = U({
      get() {
        return e[t.nameFrom];
      },
      set(A) {
        e[t.nameFrom] = A, L(A), n.touched = !0, de(() => {
          o("change");
        });
      }
    }), { timeIntervalOptions: m, getTimeIntervalOption: i } = Jt(t.allowed), r = V(null), y = V(!1), s = V({
      from: null,
      until: Ee()
    }), a = V(!1), { v$: h } = Yt(s), g = U(() => n.fields[t.nameFrom]), { t: l } = le(), B = U(() => g.value.titleT ? l(g.value.titleT) : void 0), { clearOne: R } = Ue(), { showValidationError: k } = He(), F = () => {
      a.value = !1, r.value = null, $();
    }, w = () => {
      if (h.value.$touch(), h.value.$invalid) {
        k();
        return;
      }
      a.value = !0, y.value = !1, e[t.nameUntil] = s.value.until, p.value = s.value.from;
    }, x = () => {
      y.value = !1, r.value = null;
    }, $ = () => {
      R(t.nameFrom, e, n), R(t.nameUntil, e, n), c.value.delete(t.nameFrom);
    }, L = (A) => {
      if (_e(A) || we(A)) return;
      if (Y(A) || T(A)) {
        c.value.delete(t.nameFrom);
        return;
      }
      const S = i(A);
      if (!S && Ne(A)) {
        const Q = i(Le.Custom);
        c.value.set(t.nameFrom, [
          {
            title: Q.title + ": " + Se(s.value.from) + " - " + Se(s.value.until),
            value: A
          }
        ]);
        return;
      }
      S && c.value.set(t.nameFrom, [{ title: S.title, value: A }]);
    }, O = (A = !1) => {
      h.value.$reset(), A && (s.value.from = null, s.value.until = Ee()), y.value = !0;
    };
    se(
      p,
      (A) => {
        if (_e(A) || we(A)) return;
        if (a.value = !1, T(A) || Y(A)) {
          r.value = null;
          return;
        }
        const S = i(p.value), Q = e[t.nameUntil];
        !S && Ne(p.value) && Ne(Q) && (r.value = Le.Custom, s.value.from = p.value, s.value.until = Q, a.value = !0), S && (r.value = S.value);
      },
      { immediate: !0 }
    ), se(
      [() => e[t.nameFrom], () => e[t.nameUntil]],
      ([A, S], [Q, J]) => {
        A === Q && S === J || L(A);
      },
      { immediate: !0 }
    );
    const oe = (A) => {
      if (A.value === Le.Custom) {
        O(!0);
        return;
      }
      e[t.nameUntil] = null, p.value = A.value;
    };
    return (A, S) => {
      const Q = be("ABtnTertiary"), J = be("ABtnPrimary");
      return C(), I(te, null, [
        a.value ? (C(), E(wa, {
          key: 0,
          label: B.value,
          "model-value": _(Se)(s.value.from) + " - " + _(Se)(s.value.until),
          readonly: "",
          rows: "1",
          "auto-grow": "",
          "hide-details": "",
          "append-inner-icon": "mdi-menu-down",
          clearable: "",
          class: "cursor-pointer",
          "onClick:clear": M(F, ["stop"]),
          onClick: S[0] || (S[0] = M((X) => O(), ["stop"]))
        }, null, 8, ["label", "model-value"])) : (C(), E(_a, {
          key: 1,
          modelValue: r.value,
          "onUpdate:modelValue": S[1] || (S[1] = (X) => r.value = X),
          "item-title": "title",
          "item-value": "value",
          label: B.value,
          clearable: !_(Y)(r.value),
          "no-filter": "",
          "data-cy": A.dataCy,
          items: _(m),
          "hide-details": "",
          autocomplete: "off",
          "onClick:clear": M(F, ["stop"])
        }, {
          item: f(({ props: X, item: re }) => [
            u(vt, ct(X, {
              onClick: (ve) => oe(re)
            }), null, 16, ["onClick"])
          ]),
          _: 1
        }, 8, ["modelValue", "label", "clearable", "data-cy", "items"])),
        y.value ? (C(), E(mt, {
          key: 2,
          "model-value": !0,
          width: "auto",
          "min-width": 360
        }, {
          default: f(() => [
            u(dt, null, {
              default: f(() => [
                u(Ke, { onOnCancel: x }, {
                  default: f(() => [
                    K(A.$slots, "title", {}, () => [
                      j(D(B.value), 1)
                    ], !0)
                  ]),
                  _: 3
                }),
                u(It, null, {
                  default: f(() => [
                    u(ue, null, {
                      default: f(() => [
                        u(bt, {
                          modelValue: s.value.from,
                          "onUpdate:modelValue": S[2] || (S[2] = (X) => s.value.from = X),
                          v: _(h).dialogData.from,
                          label: _(l)("common.filter.timeInterval.from"),
                          required: ""
                        }, null, 8, ["modelValue", "v", "label"])
                      ]),
                      _: 1
                    }),
                    u(ue, null, {
                      default: f(() => [
                        u(bt, {
                          modelValue: s.value.until,
                          "onUpdate:modelValue": S[3] || (S[3] = (X) => s.value.until = X),
                          v: _(h).dialogData.until,
                          label: _(l)("common.filter.timeInterval.until"),
                          required: ""
                        }, null, 8, ["modelValue", "v", "label"])
                      ]),
                      _: 1
                    })
                  ]),
                  _: 1
                }),
                u(Ut, null, {
                  default: f(() => [
                    u(ft),
                    u(Q, {
                      "data-cy": "button-cancel",
                      onClick: M(x, ["stop"])
                    }, {
                      default: f(() => [
                        j(D(_(l)("common.button.cancel")), 1)
                      ]),
                      _: 1
                    }),
                    u(J, {
                      "data-cy": "button-confirm",
                      onClick: M(w, ["stop"])
                    }, {
                      default: f(() => [
                        j(D(_(l)("common.button.confirm")), 1)
                      ]),
                      _: 1
                    })
                  ]),
                  _: 1
                })
              ]),
              _: 3
            })
          ]),
          _: 3
        })) : W("", !0)
      ], 64);
    };
  }
}), es = /* @__PURE__ */ Qt(Ia, [["__scopeId", "data-v-622f5681"]]), ts = /* @__PURE__ */ ae({
  __name: "AFilterValueObjectOptionsSelect",
  props: {
    name: {},
    items: {}
  },
  emits: ["change"],
  setup(b, { emit: d }) {
    const t = b, o = d, v = N(qe), c = N(Te), n = N(he), e = N(Ce), p = ha()?.type.__name;
    if (T(v) || T(c) || T(e) || T(n))
      throw new Error(`[${p}] Incorrect provide/inject config.`);
    if (
      // eslint-disable-next-line vue/no-setup-props-reactivity-loss
      T(n.fields[t.name]) || // eslint-disable-next-line vue/no-setup-props-reactivity-loss
      T(e[t.name])
    )
      throw new Error(
        `[${p}] Incorrect filter config. Name is '${t.name}' and available options are ${Object.keys(e).join(", ")}.`
      );
    const m = U({
      get() {
        return e[t.name];
      },
      set(g) {
        e[t.name] = g, h(), n.touched = !0, o("change");
      }
    }), i = U(() => n.fields[t.name]), { t: r } = le(), y = U(() => i.value.titleT ? r(i.value.titleT) : void 0), { clearOne: s } = Ue(), a = () => {
      s(t.name, e, n), c.value.delete(t.name);
    }, h = () => {
      if (_e(m.value) && m.value.length === 0) return;
      if (_e(m.value)) {
        c.value.set(
          t.name,
          m.value.map((l) => {
            const B = t.items.find((R) => R.value === l);
            return B ? { title: B.title, value: B.value } : { title: l, value: l };
          })
        );
        return;
      }
      const g = t.items.find((l) => l.value === m.value);
      g && c.value.set(t.name, [{ title: g.title, value: g.value }]);
    };
    return se(
      () => e[t.name],
      (g, l) => {
        g === l || we(g) || h();
      },
      { immediate: !0 }
    ), (g, l) => (C(), E(Aa, {
      modelValue: m.value,
      "onUpdate:modelValue": l[0] || (l[0] = (B) => m.value = B),
      items: g.items,
      chips: i.value.multiple,
      label: y.value,
      multiple: i.value.multiple,
      clearable: !i.value.mandatory,
      "data-cy": "filter-value",
      "hide-details": "",
      autocomplete: "off",
      "onClick:clear": M(a, ["stop"])
    }, null, 8, ["modelValue", "items", "chips", "label", "multiple", "clearable"]));
  }
}), Ua = /* @__PURE__ */ ae({
  __name: "AFilterAdvancedButton",
  props: {
    tooltipT: { default: "common.button.advancedFilters" },
    buttonClass: { default: "mt-1" },
    dataCy: { default: "filter-advanced" }
  },
  emits: ["advancedFilter"],
  setup(b, { emit: d }) {
    const t = d, o = V(!1), v = (n) => {
      Pt(n), o.value = !o.value, t("advancedFilter");
    }, { t: c } = le();
    return (n, e) => (C(), E(G, {
      class: Be(n.buttonClass),
      "data-cy": n.dataCy,
      icon: "",
      size: "x-small",
      variant: "text",
      onClick: M(v, ["stop"])
    }, {
      default: f(() => [
        u(ye, { icon: "mdi-filter-variant" }),
        u(Fe, {
          activator: "parent",
          location: "bottom"
        }, {
          default: f(() => [
            j(D(_(c)(n.tooltipT)), 1)
          ]),
          _: 1
        })
      ]),
      _: 1
    }, 8, ["class", "data-cy"]));
  }
}), Ra = { class: "a-selected-filters__label text-caption" }, Oa = /* @__PURE__ */ ae({
  __name: "FiltersSelected",
  setup(b) {
    const d = N(he), t = N(Ce), o = N(Te);
    if (T(d) || T(t) || T(o))
      throw new Error("Incorrect provide/inject config.");
    const { t: v } = le(), c = (i) => {
      const r = d.fields?.[i]?.titleT;
      return r ? v(r) : i;
    }, n = U(() => {
      const i = Object.keys(d.fields);
      return Array.from(o.value).map(([r, y]) => ({
        name: r,
        title: c(r),
        options: y
      })).sort((r, y) => i.indexOf(r.name) - i.indexOf(y.name));
    }), { clearOneFilterSelected: e, isClearable: p } = Ue(), m = (i, r) => {
      e(i, r, t, d, o), d.touched = !0;
    };
    return (i, r) => (C(!0), I(te, null, me(n.value, (y) => (C(), I("div", {
      key: y.name,
      class: "a-selected-filters"
    }, [
      z("div", Ra, D(y.title) + ": ", 1),
      (C(!0), I(te, null, me(y.options, (s) => (C(), I("div", {
        key: s.value,
        class: "a-selected-filters__chips"
      }, [
        _(p)(y.name, _(d)) ? (C(), E(wt, {
          key: 0,
          closable: "",
          size: "small",
          class: "a-selected-filters__chip",
          "onClick:close": M((a) => m(y.name, s.value), ["stop"])
        }, {
          close: f(() => [
            u(ye, {
              size: "16",
              icon: "mdi-close-circle"
            })
          ]),
          default: f(() => [
            j(" " + D(s.title), 1)
          ]),
          _: 2
        }, 1032, ["onClick:close"])) : (C(), E(wt, {
          key: 1,
          size: "small",
          class: "a-selected-filters__chip"
        }, {
          default: f(() => [
            j(D(s.title), 1)
          ]),
          _: 2
        }, 1024))
      ]))), 128))
    ]))), 128));
  }
});
function Tt(b, d = "userAdminConfig") {
  const t = [
    { name: "user", default: null },
    { name: "configType", default: null },
    { name: "layoutType", default: null },
    { name: "systemResource", default: null },
    { name: "customName", default: null },
    { name: "defaultConfig", default: null }
  ], { filterConfig: o, filterData: v } = Xt(t, Gt(t), {
    system: b,
    subject: d
  });
  return {
    filterConfig: o,
    filterData: v
  };
}
const Ie = {
  PinnedWidgets: "pinnedWidgets",
  FilterBookmark: "filterBookmark"
}, ja = Ie.PinnedWidgets, ce = {
  Desktop: "desktop",
  Mobile: "mobile"
}, Na = ce.Desktop, La = 3, Me = 8, Nt = Fa("filterBookmarkStore", () => {
  const b = V(/* @__PURE__ */ new Map()), d = V(!1);
  function t(e, p) {
    return `userAdminConfig/${p}/${e}/`;
  }
  function o() {
    let e = null, p = 1 / 0;
    b.value.forEach((m, i) => {
      m.lastUsed < p && (p = m.lastUsed, e = i);
    }), e !== null && b.value.delete(e);
  }
  async function v(e, p, m = !1) {
    d.value = !1;
    const i = t(e.layoutType, e.systemResource), r = Date.now();
    if (!m) {
      const B = b.value.get(i);
      if (B)
        return B.lastUsed = r, B.items;
    }
    const { pagination: y } = Ve("position", ee.Asc, {
      rowsPerPage: Me
    }), { start: s, end: a } = yt(e.systemResource, "_"), { filterConfig: h, filterData: g } = Tt(s, a);
    g.configType = Ie.FilterBookmark, g.layoutType = e.layoutType, g.systemResource = e.systemResource, g.user = e.user;
    let l = [];
    try {
      const { executeFetch: B } = p();
      l = await B(y, g, h), b.value.set(i, { lastUsed: r, items: l });
    } catch {
      d.value = !0;
    }
    return b.value.size > La && o(), l;
  }
  async function c(e, p) {
    d.value = !1;
    const { pagination: m } = Ve("position", ee.Asc, {
      rowsPerPage: Me + 1
    }), { start: i, end: r } = yt(e.systemResource, "_"), { filterConfig: y, filterData: s } = Tt(i, r);
    s.configType = Ie.FilterBookmark, s.layoutType = e.layoutType, s.systemResource = e.systemResource, s.user = e.user;
    let a = 1 / 0;
    try {
      const { executeFetch: h } = p();
      a = (await h(m, s, y)).length;
    } catch {
      d.value = !0;
    }
    return a;
  }
  function n(e, p) {
    b.value.get(e)?.items.push(p);
  }
  return {
    bookmarks: b,
    error: d,
    getBookmarks: v,
    generateKey: t,
    addOne: n,
    fetchBookmarksCount: c
  };
}), ke = (b, d, t, o, v = void 0, c = void 0, n = {}) => {
  let e = null;
  return {
    executeRequest: async (i = void 0, r = void 0, y = void 0) => {
      e = new AbortController();
      try {
        const s = { method: d }, a = Z(r) ? r : c, h = Z(i) ? i : v;
        if (T(h)) throw new Error("Url template is undefined");
        s.url = h, h !== "" && !T(a) && (s.url = We(h, a)), Y(y) || (s.data = JSON.stringify(y));
        const g = await b().request({
          ...n,
          ...s,
          signal: e.signal
        });
        if (!Je(g.status))
          throw new Ye(g.status);
        if (g.data)
          return g.data;
        if (g.status === Qe)
          return;
        throw new ge();
      } catch (s) {
        if (s instanceof DOMException && s.name === "AbortError")
          return [];
        throw Xe(s) ? s : Ge(s) ? new Ze(s, s.config?.url) : et(s) ? new tt(s, t, o, s) : at(s) ? new ot(s, t, o, s) : st(s) ? new nt(s, s) : lt(s) ? new rt(s) : pt.isAxiosError(s) ? (console.error("Axios error: " + v, s.cause), new it(s)) : (console.error("AnzuFatalError: ", s), new ge(s));
      } finally {
        e = null;
      }
    },
    abortRequest: () => {
      e && e.abort();
    }
  };
}, Bt = "/adm/v1/user-admin-config", za = "userAdminConfig";
function Lt(b, d, t = za, o = Bt) {
  return {
    useFetchUserAdminConfigList: () => St(b, d, t, Bt),
    fetchUserAdminConfig: (i) => {
      const { executeRequest: r } = ke(b, "GET", d, t);
      return r(o + "/:id", { id: i });
    },
    createUserAdminConfig: (i) => {
      const { executeRequest: r } = ke(b, "POST", d, t);
      return r(o, void 0, i);
    },
    updateUserAdminConfig: (i, r) => {
      const { executeRequest: y } = ke(b, "PUT", d, t);
      return y(o + "/:id", { id: i }, r);
    },
    deleteUserAdminConfig: (i) => {
      const { executeRequest: r } = ke(b, "DELETE", d, t);
      return r(o + "/:id", { id: i });
    },
    updateUserAdminConfigPositions: (i) => {
      const { executeRequest: r } = ke(b, "PATCH", d, t);
      return r(o + "/update-positions", void 0, { userAdminConfigs: i });
    }
  };
}
function Ma() {
  return {
    createDefaultUserAdminConfig: (d) => ({
      id: 0,
      user: 0,
      configType: ja,
      layoutType: Na,
      systemResource: "",
      customName: "",
      defaultConfig: !1,
      data: [],
      position: 0,
      createdAt: Ee(),
      modifiedAt: Ee(),
      createdBy: null,
      modifiedBy: null,
      _resourceName: "userAdminConfig",
      _system: d
    })
  };
}
const qa = {
  key: 0,
  class: "w-100 pt-4"
}, Ha = {
  key: 1,
  class: "w-100 pt-4"
}, Ka = {
  key: 0,
  class: "d-flex w-100 align-center justify-center"
}, Wa = { key: 1 }, Ja = {
  key: 0,
  class: "d-flex align-center justify-end"
}, Ya = /* @__PURE__ */ ae({
  __name: "FilterBookmarkDialog",
  props: {
    client: {},
    system: {},
    subject: {},
    user: {},
    datatableHiddenColumns: { default: void 0 }
  },
  emits: ["onClose"],
  setup(b, { emit: d }) {
    const t = b, o = d, v = N(he), c = N(Ce), n = N(Re);
    if (T(n) || T(v) || T(c))
      throw new Error("Incorrect provide/inject config.");
    const e = V("add"), p = V(""), m = V(!1), i = V(!1), r = V(!1), y = V(!1), s = V(!1), a = V([]), h = V(null), { required: g, maxLength: l } = Zt(), B = {
      customName: {
        required: g,
        maxLength: l(100)
      }
    }, R = At(B, { customName: p }, { $stopPropagation: !0 }), k = {
      itemEdit: {
        required: g,
        maxLength: l(100)
      }
    }, F = At(k, { itemEdit: h }, { $stopPropagation: !0 }), w = Nt(), {
      createUserAdminConfig: x,
      useFetchUserAdminConfigList: $,
      updateUserAdminConfigPositions: L,
      deleteUserAdminConfig: O,
      updateUserAdminConfig: oe
    } = (
      // eslint-disable-next-line vue/no-setup-props-reactivity-loss
      Lt(t.client, t.system)
    ), { t: A } = le(), { showErrorsDefault: S, showValidationError: Q, showWarningT: J } = He(), { createDefaultUserAdminConfig: X } = Ma(), re = async () => {
      r.value = !0;
      const P = a.value.map((ne) => ne.id);
      try {
        await L(P), r.value = !1, await Pe(), o("onClose");
      } catch (ne) {
        S(ne), r.value = !1;
      }
    }, { serializeFilters: ve } = ut(c, v), ie = t.system + "_" + t.subject, zt = async () => {
      r.value = !0, s.value = !1;
      const q = X(t.system);
      q.user = t.user, q.configType = Ie.FilterBookmark, q.layoutType = ce.Desktop, q.systemResource = ie, q.customName = p.value, q.data = {
        filter: ve(c, n, !1),
        datatableHiddenColumns: m.value && t.datatableHiddenColumns ? t.datatableHiddenColumns : void 0,
        sortBy: i.value && n.value.sortBy ? n.value.sortBy : void 0
      };
      try {
        const P = await w.fetchBookmarksCount(
          {
            user: t.user,
            layoutType: ce.Desktop,
            systemResource: ie
          },
          $
        );
        if (P >= Me) {
          s.value = !0, r.value = !1;
          return;
        }
        q.position = P + 1;
        const ne = await x(q);
        w.addOne(
          w.generateKey(ce.Desktop, ie),
          ne
        ), o("onClose");
      } catch (P) {
        if (ta(P) && aa(P, "error_field_not_unique", "cms.userAdminConfig.model.systemResource")) {
          J("common.filter.bookmark.nameUniqueError");
          return;
        }
        S(P);
      } finally {
        r.value = !1;
      }
    }, Mt = () => {
      if (e.value === "add") {
        if (R.value.$touch(), R.value.$invalid) {
          Q();
          return;
        }
        zt();
      } else e.value === "manage" && a.value.length > 0 && re();
    }, qt = async (q) => {
      y.value = !0;
      try {
        await O(q.raw.id), await Pe(), Oe();
      } catch (P) {
        S(P);
      } finally {
        y.value = !1;
      }
    }, gt = $t("inputRef"), Ht = async (q) => {
      h.value = { id: q.raw.id, customName: q.raw.customName }, await de(), gt.value?.focus();
    }, Kt = async (q) => {
      if (Y(h.value)) return;
      y.value = !0;
      const P = Dt(q.raw);
      P.customName = h.value.customName;
      try {
        Oe(), await oe(P.id, P), await Pe();
      } catch (ne) {
        S(ne);
      } finally {
        y.value = !1;
      }
    }, Oe = () => {
      h.value = null;
    }, Pe = async () => {
      y.value = !0;
      try {
        a.value = await w.getBookmarks(
          {
            user: t.user,
            layoutType: ce.Desktop,
            systemResource: ie
          },
          $,
          !0
        );
      } catch (q) {
        S(q);
      } finally {
        y.value = !1;
      }
    };
    return se(e, () => {
      s.value = !1, e.value === "manage" && Pe();
    }), (q, P) => {
      const ne = be("ABtnTertiary"), Wt = be("ABtnPrimary");
      return C(), E(mt, {
        "model-value": !0,
        width: 500
      }, {
        default: f(() => [
          u(dt, null, {
            default: f(() => [
              u(Ke, {
                onOnCancel: P[0] || (P[0] = (H) => o("onClose"))
              }, {
                default: f(() => [
                  j(D(_(A)("common.filter.bookmark.title")), 1)
                ]),
                _: 1
              }),
              u(It, { class: "pt-0" }, {
                default: f(() => [
                  u(Ba, {
                    modelValue: e.value,
                    "onUpdate:modelValue": P[1] || (P[1] = (H) => e.value = H),
                    "fixed-tabs": ""
                  }, {
                    default: f(() => [
                      u(Ft, { value: "add" }, {
                        default: f(() => [
                          j(D(_(A)("common.filter.bookmark.add")), 1)
                        ]),
                        _: 1
                      }),
                      u(Ft, { value: "manage" }, {
                        default: f(() => [
                          j(D(_(A)("common.filter.bookmark.manage")), 1)
                        ]),
                        _: 1
                      })
                    ]),
                    _: 1
                  }, 8, ["modelValue"]),
                  e.value === "add" ? (C(), I("div", qa, [
                    u(ue, {
                      title: _(A)("common.filter.bookmark.infoSave")
                    }, null, 8, ["title"]),
                    s.value ? (C(), E(ue, {
                      key: 0,
                      class: "text-error",
                      title: _(A)("common.filter.bookmark.errorMax")
                    }, null, 8, ["title"])) : W("", !0),
                    u(ue, null, {
                      default: f(() => [
                        u(ht, {
                          modelValue: p.value,
                          "onUpdate:modelValue": P[2] || (P[2] = (H) => p.value = H),
                          label: _(A)("common.filter.bookmark.name"),
                          required: "",
                          v: _(R).customName
                        }, null, 8, ["modelValue", "label", "v"])
                      ]),
                      _: 1
                    }),
                    u(ue, null, {
                      default: f(() => [
                        u(Ct, {
                          modelValue: m.value,
                          "onUpdate:modelValue": P[3] || (P[3] = (H) => m.value = H),
                          label: _(A)("common.filter.bookmark.storeTableColumns")
                        }, null, 8, ["modelValue", "label"])
                      ]),
                      _: 1
                    }),
                    u(ue, null, {
                      default: f(() => [
                        u(Ct, {
                          modelValue: i.value,
                          "onUpdate:modelValue": P[4] || (P[4] = (H) => i.value = H),
                          label: _(A)("common.filter.bookmark.storeTableOrder")
                        }, null, 8, ["modelValue", "label"])
                      ]),
                      _: 1
                    })
                  ])) : e.value === "manage" ? (C(), I("div", Ha, [
                    y.value ? (C(), I("div", Ka, [
                      u(Ta, { indeterminate: "" })
                    ])) : (C(), E(ea, {
                      key: 1,
                      modelValue: a.value,
                      "onUpdate:modelValue": P[7] || (P[7] = (H) => a.value = H),
                      "show-edit-button": "",
                      "show-delete-button": "",
                      "permanent-buttons": "",
                      onOnDelete: qt,
                      onOnEdit: Ht
                    }, Ca({
                      item: f(({ item: H }) => [
                        h.value && h.value.id === H.raw.id ? (C(), E(ht, {
                          key: 0,
                          ref_key: "inputRef",
                          ref: gt,
                          modelValue: h.value.customName,
                          "onUpdate:modelValue": P[5] || (P[5] = (je) => h.value.customName = je),
                          "hide-details": "auto",
                          v: _(F)
                        }, null, 8, ["modelValue", "v"])) : (C(), I("div", Wa, D(H.raw.customName), 1))
                      ]),
                      _: 2
                    }, [
                      _(Y)(h.value) ? void 0 : {
                        name: "item-buttons",
                        fn: f(({ item: H }) => [
                          h.value && h.value.id === H.raw.id ? (C(), I("div", Ja, [
                            u(G, {
                              icon: "",
                              size: "x-small",
                              variant: "text",
                              class: "mx-1",
                              onClick: M((je) => Kt(H), ["stop"])
                            }, {
                              default: f(() => [
                                u(ye, { icon: "mdi-check" }),
                                u(Fe, {
                                  anchor: "bottom",
                                  activator: "parent",
                                  text: _(A)("common.button.confirm")
                                }, null, 8, ["text"])
                              ]),
                              _: 1
                            }, 8, ["onClick"]),
                            u(G, {
                              icon: "",
                              size: "x-small",
                              variant: "text",
                              class: "mx-1",
                              onClick: P[6] || (P[6] = M((je) => Oe(), ["stop"]))
                            }, {
                              default: f(() => [
                                u(ye, { icon: "mdi-close" }),
                                u(Fe, {
                                  anchor: "bottom",
                                  activator: "parent",
                                  text: _(A)("common.button.cancel")
                                }, null, 8, ["text"])
                              ]),
                              _: 1
                            })
                          ])) : W("", !0)
                        ]),
                        key: "0"
                      }
                    ]), 1032, ["modelValue"]))
                  ])) : W("", !0)
                ]),
                _: 1
              }),
              u(Ut, null, {
                default: f(() => [
                  u(ft),
                  u(ne, {
                    "data-cy": "button-cancel",
                    onClick: P[8] || (P[8] = M((H) => o("onClose"), ["stop"]))
                  }, {
                    default: f(() => [
                      j(D(_(A)("common.button.cancel")), 1)
                    ]),
                    _: 1
                  }),
                  u(Wt, {
                    "data-cy": "button-confirm",
                    loading: r.value,
                    onClick: M(Mt, ["stop"])
                  }, {
                    default: f(() => [
                      j(D(e.value === "add" ? _(A)("common.button.add") : _(A)("common.filter.bookmark.saveBookmarkOrder")), 1)
                    ]),
                    _: 1
                  }, 8, ["loading"])
                ]),
                _: 1
              })
            ]),
            _: 1
          })
        ]),
        _: 1
      });
    };
  }
}), Qa = /* @__PURE__ */ ae({
  __name: "AFilterBookmarkButton",
  props: /* @__PURE__ */ fe({
    client: {},
    system: {},
    subject: {},
    user: {},
    tooltipT: { default: "common.button.bookmarkFilter" },
    buttonClass: { default: "ml-2" },
    dataCy: { default: "filter-bookmark" },
    datatableHiddenColumns: { default: void 0 },
    datatableSortBy: { default: void 0 }
  }, {
    dialog: { type: Boolean, default: !1, required: !1 },
    dialogModifiers: {}
  }),
  emits: ["update:dialog"],
  setup(b) {
    const d = Ae(b, "dialog"), t = (v) => {
      Pt(v), d.value = !0;
    }, { t: o } = le();
    return (v, c) => (C(), I(te, null, [
      u(G, {
        class: Be([v.buttonClass, "px-2"]),
        "data-cy": v.dataCy,
        color: "light",
        "min-width": "36px",
        variant: "flat",
        onClick: M(t, ["stop"])
      }, {
        default: f(() => [
          u(ye, {
            color: "grey darken-1",
            icon: "mdi-bookmark-outline"
          }),
          u(Fe, {
            activator: "parent",
            location: "bottom"
          }, {
            default: f(() => [
              j(D(_(o)(v.tooltipT)), 1)
            ]),
            _: 1
          })
        ]),
        _: 1
      }, 8, ["class", "data-cy"]),
      d.value ? (C(), E(Ya, {
        key: 0,
        client: v.client,
        system: v.system,
        user: v.user,
        subject: v.subject,
        "datatable-hidden-columns": v.datatableHiddenColumns,
        onOnClose: c[0] || (c[0] = (n) => d.value = !1)
      }, null, 8, ["client", "system", "user", "subject", "datatable-hidden-columns"])) : W("", !0)
    ], 64));
  }
}), Xa = { key: 0 }, Ga = 32, Za = /* @__PURE__ */ ae({
  __name: "FilterBookmarks",
  props: /* @__PURE__ */ fe({
    client: {},
    userId: {},
    system: {},
    subject: {}
  }, {
    datatableHiddenColumns: {
      default: void 0,
      required: !0
    },
    datatableHiddenColumnsModifiers: {}
  }),
  emits: /* @__PURE__ */ fe(["submit"], ["update:datatableHiddenColumns"]),
  setup(b, { emit: d }) {
    const t = b, o = d, v = Ae(b, "datatableHiddenColumns"), c = N(he), n = N(Ce), e = N(Re), p = N(Te);
    if (T(e) || T(c) || T(n) || T(p))
      throw new Error("Incorrect provide/inject config.");
    const m = V(!1), i = $t("toolbar"), r = V(300), y = V(1e3), s = Nt(), { useFetchUserAdminConfigList: a } = Lt(t.client, t.system), h = t.system + "_" + t.subject, g = async (w = !1) => {
      m.value = !0, await s.getBookmarks(
        {
          user: t.userId,
          layoutType: ce.Desktop,
          systemResource: h
        },
        a,
        w
      ), m.value = !1;
    }, { deserializeFilters: l } = ut(n, c), B = (w) => {
      const x = w.data;
      Z(x.datatableHiddenColumns) && Z(v.value) && (v.value = x.datatableHiddenColumns), Z(x.sortBy) && (e.value = { ...e.value, sortBy: { key: x.sortBy.key, order: x.sortBy.order } });
      const $ = l(x.filter);
      if (!Y($)) {
        for (const L in n) {
          const O = L, oe = $.filters[O];
          if (T(oe) && c.fields[O]?.clearable) {
            n[O] = Dt(c.fields[O].default), p.value.delete(O);
            continue;
          }
          n[O] = oe;
        }
        o("submit");
      }
    }, R = async (w) => {
      const x = i.value;
      if (Y(x)) return;
      y.value = 1e3, await de();
      let $ = 0, L = 0;
      for (let O = 0; O < x.children.length; O++) {
        const A = x.children[O].offsetWidth;
        if ($ += A, $ >= w - Ga)
          break;
        L++;
      }
      y.value = L;
    };
    Pa(i, (w) => {
      w[0] && (r.value = w[0].contentRect.width);
    }), Sa(
      r,
      (w, x) => {
        w !== x && R(w);
      },
      { throttle: 1e3 }
    );
    const k = U(() => {
      const w = s.generateKey(ce.Desktop, h);
      return s.bookmarks.get(w)?.items ?? [];
    }), F = U(() => {
      const w = y.value;
      return {
        visible: k.value.slice(0, w),
        hidden: k.value.slice(w)
      };
    });
    return se([m, () => k.value.length], ([w]) => {
      w === !0 || Y(i.value) || (r.value = i.value.clientWidth, de(() => {
        R(r.value);
      }));
    }), xt(() => {
      g();
    }), (w, x) => (C(), I("div", {
      ref: "toolbar",
      key: k.value.length,
      class: "w-100 d-flex overflow-hidden align-center mb-1"
    }, [
      m.value ? (C(), I("div", Xa)) : (C(), I(te, { key: 1 }, [
        (C(!0), I(te, null, me(F.value.visible, ($) => (C(), I("div", {
          key: $.id,
          class: "white-space-nowrap"
        }, [
          u(G, {
            text: "",
            "prepend-icon": "mdi-bookmark-outline",
            size: "small",
            class: "mr-1 mb-1 bg-grey-lighten-4 text-grey-darken-3",
            onClick: (L) => B($)
          }, {
            default: f(() => [
              j(D($.customName), 1)
            ]),
            _: 2
          }, 1032, ["onClick"])
        ]))), 128)),
        F.value.hidden.length > 0 ? (C(), E(jt, {
          key: 0,
          bottom: "",
          "offset-y": ""
        }, {
          activator: f(({ props: $ }) => [
            u(G, ct({
              icon: "mdi-menu-down",
              size: "x-small",
              width: 28,
              height: 28
            }, $), null, 16)
          ]),
          default: f(() => [
            u(Rt, { density: "compact" }, {
              default: f(() => [
                (C(!0), I(te, null, me(F.value.hidden, ($) => (C(), E(vt, {
                  key: $.id,
                  onClick: (L) => B($)
                }, {
                  default: f(() => [
                    u(Ot, null, {
                      default: f(() => [
                        j(D($.customName), 1)
                      ]),
                      _: 2
                    }, 1024)
                  ]),
                  _: 2
                }, 1032, ["onClick"]))), 128))
              ]),
              _: 1
            })
          ]),
          _: 1
        })) : W("", !0)
      ], 64))
    ]));
  }
}), eo = { class: "d-flex flex-wrap align-center" }, to = { class: "a-filter__container" }, ao = { class: "a-filter__search" }, oo = { key: 2 }, as = /* @__PURE__ */ ae({
  __name: "AFilterWrapper",
  props: /* @__PURE__ */ fe({
    enableTop: { type: Boolean, default: !1 },
    hideButtons: { type: Boolean, default: !1 },
    formName: { default: "search" },
    userId: { default: void 0 },
    client: { type: Function, default: void 0 },
    store: { type: [Object, Boolean], default: !0 },
    alwaysVisible: { type: Boolean, default: !1 },
    hideMore: { type: Boolean, default: !1 }
  }, {
    datatableHiddenColumns: {
      default: void 0,
      required: !1
    },
    datatableHiddenColumnsModifiers: {},
    showDetail: { type: Boolean, default: !1, required: !1 },
    showDetailModifiers: {}
  }),
  emits: /* @__PURE__ */ fe(["submit", "reset", "bookmarkLoadAfter"], ["update:datatableHiddenColumns", "update:showDetail"]),
  setup(b, { expose: d, emit: t }) {
    const o = b, v = t, c = Ae(b, "datatableHiddenColumns"), n = Ae(b, "showDetail"), e = N(he), p = N(Ce);
    if (T(e) || T(p))
      throw new Error("Incorrect provide/inject config.");
    const m = V({
      system: e.general.system,
      subject: e.general.subject
    });
    we(o.store) ? o.store === !1 && (m.value.system = void 0, m.value.subject = void 0) : (m.value.system = o.store.system, m.value.subject = o.store.subject);
    const i = V(0);
    kt(qe, i);
    const r = V(/* @__PURE__ */ new Map());
    kt(Te, r);
    const y = () => {
      i.value++, de(() => {
        v("submit");
      });
    }, { clearAll: s, clearAllFilterSelected: a } = Ue(), h = () => {
      de(() => {
        i.value++, v("bookmarkLoadAfter");
      });
    }, g = () => {
      s(p, e), a(p, e, r), de(() => {
        i.value++, v("reset");
      });
    }, l = () => {
      n.value = !n.value;
    }, B = U(() => e.touched), R = U(() => Object.entries(e.fields).filter(([, k]) => !k.render.skip).map(([k]) => k));
    return o.alwaysVisible && (n.value = !0), d({
      submit: y,
      reset: g
    }), (k, F) => (C(), E($a, {
      name: k.formName,
      onSubmit: M(y, ["prevent"])
    }, {
      default: f(() => [
        k.enableTop ? (C(), E(De, {
          key: 0,
          dense: ""
        }, {
          default: f(() => [
            u(pe, null, {
              default: f(() => [
                K(k.$slots, "top")
              ]),
              _: 3
            })
          ]),
          _: 3
        })) : W("", !0),
        u(De, { dense: "" }, {
          default: f(() => [
            k.store && k.userId && _(Z)(k.client) ? (C(), E(pe, { key: 0 }, {
              default: f(() => [
                K(k.$slots, "bookmarks", {}, () => [
                  z("div", eo, [
                    m.value.system && m.value.subject && k.userId && _(Z)(k.client) ? (C(), E(Za, {
                      key: 0,
                      "datatable-hidden-columns": c.value,
                      "onUpdate:datatableHiddenColumns": F[0] || (F[0] = (w) => c.value = w),
                      client: k.client,
                      system: m.value.system,
                      subject: m.value.subject,
                      "user-id": k.userId,
                      onSubmit: h
                    }, null, 8, ["datatable-hidden-columns", "client", "system", "subject", "user-id"])) : W("", !0)
                  ])
                ])
              ]),
              _: 3
            })) : W("", !0)
          ]),
          _: 3
        }),
        k.alwaysVisible ? W("", !0) : (C(), E(De, {
          key: 1,
          dense: ""
        }, {
          default: f(() => [
            k.hideMore ? W("", !0) : (C(), E(pe, {
              key: 0,
              cols: "auto"
            }, {
              default: f(() => [
                u(Ua, {
                  "button-active": n.value,
                  onAdvancedFilter: l
                }, null, 8, ["button-active"])
              ]),
              _: 1
            })),
            u(pe, null, {
              default: f(() => [
                z("div", to, [
                  z("div", ao, [
                    K(k.$slots, "search")
                  ]),
                  u(Oa)
                ])
              ]),
              _: 3
            }),
            k.hideButtons ? W("", !0) : (C(), E(pe, {
              key: 1,
              class: "text-right",
              cols: "auto"
            }, {
              default: f(() => [
                K(k.$slots, "buttons", {}, () => [
                  u(oa, { touched: B.value }, null, 8, ["touched"]),
                  u(sa, { onReset: g }),
                  m.value.system && m.value.subject && k.userId && _(Z)(k.client) ? (C(), E(Qa, {
                    key: 0,
                    client: k.client,
                    user: k.userId,
                    system: m.value.system,
                    subject: m.value.subject,
                    "datatable-hidden-columns": c.value
                  }, null, 8, ["client", "user", "system", "subject", "datatable-hidden-columns"])) : W("", !0)
                ])
              ]),
              _: 3
            }))
          ]),
          _: 3
        })),
        k.hideMore ? W("", !0) : (C(), I("div", oo, [
          (C(), E(ka(k.alwaysVisible ? "div" : "VSlideYTransition"), null, {
            default: f(() => [
              Et(z("div", {
                class: Be({ "mt-6 pa-4 system-border-a": !k.alwaysVisible })
              }, [
                K(k.$slots, "detail", {}, () => [
                  u(De, null, {
                    default: f(() => [
                      (C(!0), I(te, null, me(R.value, (w) => (C(), E(pe, {
                        key: w,
                        cols: _(e).fields[w].render.xs || 12,
                        sm: _(e).fields[w].render.sm || 6,
                        md: _(e).fields[w].render.md || 4,
                        lg: _(e).fields[w].render.lg || 3,
                        xl: _(e).fields[w].render.xl || 2
                      }, {
                        default: f(() => [
                          K(k.$slots, _(na)(w), {
                            itemConfig: _(e).fields[w]
                          }, () => [
                            u(la, { name: w }, null, 8, ["name"])
                          ])
                        ]),
                        _: 2
                      }, 1032, ["cols", "sm", "md", "lg", "xl"]))), 128))
                    ]),
                    _: 3
                  })
                ])
              ], 2), [
                [Vt, n.value]
              ])
            ]),
            _: 3
          }))
        ]))
      ]),
      _: 3
    }, 8, ["name"]));
  }
}), so = { class: "d-flex align-center justify-center" }, no = { class: "text-caption mr-1" }, os = /* @__PURE__ */ ae({
  __name: "ADatatableOrdering",
  props: /* @__PURE__ */ fe({
    variant: { default: "id" },
    customOptions: { default: void 0 },
    paginationUpdateCustomCb: { type: Function, default: void 0 }
  }, {
    modelValue: {
      default: 1,
      required: !1
    },
    modelModifiers: {}
  }),
  emits: /* @__PURE__ */ fe(["sortByChange"], ["update:modelValue"]),
  setup(b, { emit: d }) {
    const t = b, o = d, v = Ae(b, "modelValue"), c = N(Re);
    if (T(c))
      throw new Error("Incorrect provide/inject config.");
    const { t: n } = le(), e = [
      { id: 1, titleT: "common.system.datatable.ordering.mostRecent", sortBy: { key: "createdAt", order: ee.Desc } },
      { id: 2, titleT: "common.system.datatable.ordering.oldest", sortBy: { key: "createdAt", order: ee.Asc } }
    ], p = [
      { id: 1, titleT: "common.system.datatable.ordering.mostRecent", sortBy: { key: "id", order: ee.Desc } },
      { id: 2, titleT: "common.system.datatable.ordering.oldest", sortBy: { key: "id", order: ee.Asc } }
    ], m = [
      {
        id: 3,
        titleT: "common.system.datatable.ordering.mostRelevant",
        sortBy: { key: ra, order: ee.Desc }
      },
      { id: 1, titleT: "common.system.datatable.ordering.mostRecent", sortBy: { key: "createdAt", order: ee.Desc } },
      { id: 2, titleT: "common.system.datatable.ordering.oldest", sortBy: { key: "createdAt", order: ee.Asc } }
    ], i = U(() => {
      const a = r.value.find((h) => h.id === v.value);
      return a ? n(a.titleT) : "";
    }), r = U(() => t.customOptions ? t.customOptions : t.variant === "most-relevant" ? m : t.variant === "id" ? p : e), y = (a) => {
      v.value = a.id;
    }, s = (a) => {
      a.sortBy || (c.value = { ...c.value, sortBy: null, descending: !0 }, o("sortByChange", a)), c.value.sortBy = a.sortBy, o("sortByChange", a);
    };
    return se(
      v,
      (a, h) => {
        if (a === h) return;
        const g = r.value.find((l) => l.id === a);
        if (!T(g)) {
          if (T(t.paginationUpdateCustomCb)) {
            s(g);
            return;
          }
          t.paginationUpdateCustomCb(g, c);
        }
      }
    ), se(
      c,
      (a, h) => {
        if (a.sortBy?.key === h?.sortBy?.key && a.sortBy?.order === h?.sortBy?.order)
          return;
        const g = r.value.find((l) => a.sortBy?.key === l.sortBy?.key && a.sortBy?.order === l.sortBy?.order);
        T(g) || (v.value = g.id);
      },
      { immediate: !0 }
    ), (a, h) => (C(), I("div", so, [
      z("div", no, D(_(n)("common.system.datatable.ordering.title")) + ": ", 1),
      u(G, {
        variant: "text",
        rounded: "xl",
        size: "small",
        "append-icon": "mdi-chevron-down"
      }, {
        default: f(() => [
          j(D(i.value) + " ", 1),
          u(jt, {
            activator: "parent",
            location: "bottom",
            "close-on-content-click": ""
          }, {
            default: f(() => [
              u(Rt, {
                density: "compact",
                class: "pa-0"
              }, {
                default: f(() => [
                  (C(!0), I(te, null, me(r.value, (g) => (C(), E(vt, {
                    key: g.id,
                    onClick: (l) => y(g)
                  }, {
                    default: f(() => [
                      u(Ot, {
                        class: Be({ "font-weight-bold": g.id === v.value })
                      }, {
                        default: f(() => [
                          j(D(_(n)(g.titleT)), 1)
                        ]),
                        _: 2
                      }, 1032, ["class"])
                    ]),
                    _: 2
                  }, 1032, ["onClick"]))), 128))
                ]),
                _: 1
              })
            ]),
            _: 1
          })
        ]),
        _: 1
      })
    ]));
  }
}), lo = { class: "anzu-data-footer" }, ro = {
  key: 0,
  class: "anzu-data-footer__page-limit"
}, io = { class: "anzu-data-footer__pagination" }, uo = { class: "anzu-data-footer__icons-before" }, co = { class: "current-page" }, mo = { class: "anzu-data-footer__icons-after" }, fo = /* @__PURE__ */ ae({
  __name: "ADatatablePagination",
  props: {
    itemsPerPageOptions: { default: () => [10, 25, 50] },
    hideRecordsPerPage: { type: Boolean, default: !1 }
  },
  emits: ["change"],
  setup(b, { emit: d }) {
    const t = d, o = N(Re);
    if (T(o))
      throw new Error("Incorrect provide/inject config.");
    const { t: v } = le(), c = U(() => Math.ceil(o.value.totalCount / o.value.rowsPerPage)), n = U(() => o.value.page * o.value.rowsPerPage - o.value.rowsPerPage + 1), e = U(() => o.value.page * o.value.rowsPerPage - o.value.rowsPerPage + o.value.currentViewCount), p = U(() => o.value.page === 1), m = U(() => !Y(o.value.hasNextPage) || o.value.page === c.value), i = U(() => Y(o.value.hasNextPage) && o.value.page === c.value || o.value.hasNextPage === !1), r = U(() => Y(o.value.hasNextPage) ? o.value.totalCount : o.value.hasNextPage ? e.value + 1 + "+" : e.value);
    se(
      () => o.value.rowsPerPage,
      (g, l) => {
        g !== l && (o.value.page = 1, t("change"));
      }
    ), se(
      () => o.value.page,
      (g, l) => {
        g !== l && t("change");
      }
    );
    const y = () => {
      o.value.page = 1;
    }, s = () => {
      o.value.page = c.value;
    }, a = () => {
      o.value.page = o.value.page - 1;
    }, h = () => {
      o.value.page = o.value.page + 1;
    };
    return (g, l) => (C(), I("div", lo, [
      g.hideRecordsPerPage ? W("", !0) : (C(), I("div", ro, [
        j(D(_(v)("common.system.datatable.itemsPerPage")) + ": ", 1),
        u(xa, {
          modelValue: _(o).rowsPerPage,
          "onUpdate:modelValue": l[0] || (l[0] = (B) => _(o).rowsPerPage = B),
          class: "ml-2",
          density: "compact",
          mandatory: "",
          "data-cy": "table-size"
        }, {
          default: f(() => [
            (C(!0), I(te, null, me(g.itemsPerPageOptions, (B) => (C(), E(G, {
              key: B,
              color: B === _(o).rowsPerPage ? "secondary" : "",
              value: B,
              density: "compact",
              size: "small",
              variant: "text"
            }, {
              default: f(() => [
                j(D(B), 1)
              ]),
              _: 2
            }, 1032, ["color", "value"]))), 128))
          ]),
          _: 1
        }, 8, ["modelValue"])
      ])),
      z("div", io, D(n.value) + " - " + D(e.value) + " " + D(_(v)("common.system.datatable.from")) + " " + D(r.value), 1),
      z("div", uo, [
        u(G, {
          disabled: p.value,
          icon: "mdi-page-first",
          size: "small",
          variant: "text",
          onClick: M(y, ["stop"])
        }, null, 8, ["disabled"]),
        u(G, {
          disabled: p.value,
          icon: "mdi-chevron-left",
          size: "small",
          variant: "text",
          onClick: M(a, ["stop"])
        }, null, 8, ["disabled"])
      ]),
      z("div", co, [
        z("span", null, D(_(o).page), 1)
      ]),
      z("div", mo, [
        u(G, {
          disabled: i.value,
          icon: "mdi-chevron-right",
          size: "small",
          variant: "text",
          onClick: M(h, ["stop"])
        }, null, 8, ["disabled"]),
        u(G, {
          disabled: m.value,
          icon: "mdi-page-last",
          size: "small",
          variant: "text",
          onClick: M(s, ["stop"])
        }, null, 8, ["disabled"])
      ])
    ]));
  }
}), vo = (b, d, t = "id") => {
  const { querySetLimit: o, querySetOffset: v, querySetOrder: c, queryBuild: n, queryAddFilter: e, queryAdd: p } = ia(), m = b.length;
  return o(m), v(1, m), c(t, !1), d ? p(t, b.join(",")) : e("in", t, b.join(",")), n();
}, ss = (b, d, t, o = void 0, v = void 0, c = {}, n = !1, e = "id") => {
  let p = null;
  return {
    executeFetch: async (r, y = void 0, s = void 0) => {
      p = new AbortController();
      try {
        const a = Z(s) ? s : v, h = Z(y) ? y : o;
        if (T(h)) throw new Error("Url template is undefined");
        const g = (T(a) ? h : We(h, a)) + vo(r, n, e), l = await b().get(g, {
          ...c,
          signal: p.signal
        });
        if (!Je(l.status))
          throw new Ye(l.status);
        if (l.data?.data)
          return l.data.data;
        if (l.status === Qe)
          return [];
        throw new ge();
      } catch (a) {
        if (a instanceof DOMException && a.name === "AbortError")
          return [];
        throw Xe(a) ? a : Ge(a) ? new Ze(a, a.config?.url) : et(a) ? new tt(a, d, t, a) : at(a) ? new ot(a, d, t, a) : st(a) ? new nt(a, a) : lt(a) ? new rt(a) : pt.isAxiosError(a) ? (console.error("Axios error: " + o, a.cause), new it(a)) : (console.error("AnzuFatalError: ", a), new ge(a));
      } finally {
        p = null;
      }
    },
    abortFetch: () => {
      p && p.abort();
    }
  };
}, ns = (b, d, t, o = void 0, v = void 0, c = {}) => {
  let n = null;
  return {
    executeFetch: async (m, i, r = void 0, y = void 0, s = "id", a = !0, h = 100, g = !1) => {
      n = new AbortController();
      try {
        const l = i.general.elastic || g ? "/search" : "", B = Z(y) ? y : v, R = Z(r) ? r : o;
        if (T(R)) throw new Error("Url template is undefined");
        const { pagination: k } = Ve(s, a ? ee.Desc : ee.Asc, {
          rowsPerPage: h
        }), F = (T(B) ? R : We(R, B)) + l, w = [], x = await b().get(F + ze(k, m, i), {
          ...c,
          signal: n.signal
        });
        if (!Je(x.status))
          throw new Ye(x.status);
        if (x.data) {
          const $ = x.data;
          if (w.push(...$.data), ua($))
            for (k.value.hasNextPage = $.hasNextPage; k.value.hasNextPage; ) {
              k.value.page++;
              const O = (await b().get(F + ze(k, m, i), {
                ...c,
                signal: n.signal
              })).data;
              w.push(...O.data), k.value.hasNextPage = O.hasNextPage;
            }
          else if (ca($)) {
            if (k.value.totalCount = $.totalCount, k.value.totalCount <= k.value.rowsPerPage)
              return w;
            const L = [], O = Math.ceil(k.value.totalCount / k.value.rowsPerPage);
            for (let A = 1; A < O; A++) {
              const S = { ...k.value, page: A + 1 }, Q = V(S);
              L.push(
                b().get(F + ze(Q, m, i), {
                  ...c,
                  signal: n.signal
                })
              );
            }
            (await Promise.all(L)).forEach((A) => {
              w.push(...A.data.data);
            });
          }
          return w;
        }
        if (x.status === Qe)
          return [];
        throw new ge();
      } catch (l) {
        if (l instanceof DOMException && l.name === "AbortError")
          return [];
        throw Xe(l) ? l : Ge(l) ? new Ze(l, l.config?.url) : et(l) ? new tt(l, d, t, l) : at(l) ? new ot(l, d, t, l) : st(l) ? new nt(l, l) : lt(l) ? new rt(l) : pt.isAxiosError(l) ? (console.error("Axios error: " + o, l.cause), new it(l)) : (console.error("AnzuFatalError: ", l), new ge(l));
      } finally {
        n = null;
      }
    },
    abortFetch: () => {
      n && n.abort();
    }
  };
}, $e = "/adm/v1/job", xe = "job";
function ls(b, d) {
  return {
    useFetchJobList: () => St(b, d, xe, $e),
    fetchJob: (n) => ma(b, $e + "/:id", { id: n }, d, xe),
    createJob: (n) => {
      const e = fa(n._resourceName).slice(4).replace("-kind-", "-kind/");
      return va(b, n, $e + "/:type", { type: e }, d, xe);
    },
    deleteJob: (n) => da(b, $e + "/:id", { id: n }, d, xe)
  };
}
const po = {
  key: "",
  title: void 0,
  sortable: !1,
  fixed: !1
}, go = {
  storeColumnsLocalStorage: !0,
  disableActions: !1,
  customI18n: void 0,
  showExpand: !1
};
function bo(b, d, t, o, v = {}) {
  const c = { ...go, ...v }, n = c.customI18n ?? pa, { t: e } = n.global || n;
  let p;
  ya(c.storeColumnsLocalStorage) ? p = c.storeColumnsLocalStorage : we(c.storeColumnsLocalStorage) && c.storeColumnsLocalStorage === !0 && (p = "table_" + t + "_" + o);
  const m = b.map((s) => {
    const a = { ...po, ...s };
    return T(a.title) && (T(a.title) && ga.includes(a.key) ? a.title = e("common.model.tracking." + a.key) : T(a.title) && t && o ? a.title = e(t + "." + o + ".model." + a.key) : a.title = ""), a;
  }), i = U(() => {
    const s = [];
    return c.showExpand && s.push({ key: "data-table-expand", sortable: !1 }), m.forEach((a) => {
      d.value.includes(a.key) || s.push(a);
    }), c.disableActions || s.push({ key: "actions", sortable: !1, fixed: "end" }), s;
  }), r = () => {
    if (!p || !localStorage) return;
    const s = localStorage.getItem(p);
    if (!s) return;
    const a = JSON.parse(s);
    ba(a) && _e(a.hidden) && (d.value = a.hidden);
  }, y = (s) => {
    !p || !localStorage || localStorage.setItem(p, JSON.stringify({ hidden: s }));
  };
  return xt(() => {
    r();
  }), se(d, (s) => {
    y(s);
  }), {
    columnsAll: m,
    columnsVisible: i,
    columnsHidden: d
  };
}
function rs(b, d, t, o, v, c, n, e = null, p = void 0, m = void 0, i = !1) {
  const r = V(!1), y = V([]), s = V([]), a = V(!1), { pagination: h, setSortBy: g, incrementPage: l } = Ve(
    Y(e) ? null : e.key,
    e?.order
  ), { resetFilter: B, submitFilter: R } = ut(c, n, {
    storeFiltersLocalStorage: !1,
    populateUrlParams: !1
  }), { showErrorsDefault: k } = He(), { columnsVisible: F, columnsAll: w, columnsHidden: x } = bo(
    b,
    d,
    t,
    o,
    { storeColumnsLocalStorage: !1, disableActions: !0 }
  ), $ = () => {
    oe(), S();
  }, L = (J) => {
    g(J.sortBy), S();
  }, O = async () => {
    a.value = !0, l();
    try {
      const J = await v(
        h,
        c,
        n,
        p,
        m,
        i
      );
      y.value.push(...J);
    } catch (J) {
      k(J);
    } finally {
      a.value = !1;
    }
  }, oe = () => {
    y.value = [], s.value = [];
  }, A = async () => {
    a.value = !0;
    try {
      y.value = await v(
        h,
        c,
        n,
        p,
        m,
        i
      );
    } catch (J) {
      k(J);
    } finally {
      a.value = !1;
    }
  }, S = Da(async () => {
    await A();
  });
  return {
    items: y,
    selected: s,
    pagination: h,
    columnsVisible: F,
    columnsHidden: x,
    columnsAll: w,
    filterTouched: r,
    loading: a,
    onRowClick: (J) => {
      const X = J.target;
      if (!X) return;
      const re = X.parentElement;
      if (!re || !re.classList.contains("v-data-table__tr")) return;
      const ve = re.firstElementChild;
      if (!ve || !ve.classList.contains("v-data-table__td")) return;
      const ie = ve.querySelector("input");
      ie && ie.click();
    },
    onFetchNextPage: O,
    onOpen: $,
    sortByChange: L,
    getList: S,
    resetFilter: () => B(h, S),
    submitFilter: () => R(h, S)
  };
}
const yo = { class: "d-flex flex-column w-100 px-1 align-center" }, ho = { class: "d-flex justify-space-between w-100 align-center" }, Co = { class: "d-flex align-center" }, ko = { class: "d-flex align-center" }, _o = { class: "subject-select__sidebar system-border-r" }, wo = { class: "subject-select-filter" }, Ao = { class: "subject-select__content" }, Fo = {
  key: 0,
  class: "d-flex w-100 align-center justify-center pa-4"
}, To = { class: "subject-select__actions system-border-t" }, Bo = { key: 0 }, Po = { key: 1 }, is = /* @__PURE__ */ ae({
  __name: "ASubjectSelect",
  props: {
    selectedItems: {},
    pagination: {},
    loading: { type: Boolean, default: !1 },
    minCount: { default: 1 },
    maxCount: { default: 1 },
    modelValue: { type: Boolean, default: void 0 },
    dialogTitleT: { default: "common.subjectSelect.texts.title" },
    paginationMode: { default: "standard" }
  },
  emits: ["update:modelValue", "update:pagination", "onOpen", "onPageChange", "onConfirm", "onFetchNextPage"],
  setup(b, { expose: d, emit: t }) {
    const o = b, v = t, c = V(!1), n = U({
      get() {
        return T(o.modelValue) ? c.value : o.modelValue;
      },
      set(F) {
        c.value = F, v("update:modelValue", F);
      }
    }), e = U({
      get: () => o.pagination,
      set: (F) => {
        v("update:pagination", { ..._t(F) });
      }
    }), p = V(!0), { t: m } = le(), i = U(() => o.selectedItems.length), r = U(() => i.value < o.minCount || i.value > o.maxCount), y = () => {
      v("onOpen"), p.value = !0, n.value = !0;
    }, s = () => {
      p.value = !p.value;
    }, a = () => {
      n.value = !1;
    }, h = () => {
      v(
        "onConfirm",
        o.selectedItems.map((F) => _t(F))
      ), a();
    }, g = () => {
      v("onFetchNextPage");
    }, l = () => {
      v("onPageChange");
    }, B = U(() => Math.ceil(e.value.totalCount / e.value.rowsPerPage)), R = U(() => !(Y(e.value.hasNextPage) && e.value.page === B.value || e.value.hasNextPage === !1)), k = (F) => {
      F && R.value && !o.loading && g();
    };
    return d({
      open: y
    }), (F, w) => {
      const x = be("ABtnSecondary"), $ = be("ABtnPrimary");
      return C(), I(te, null, [
        K(F.$slots, "activator", {
          props: { onClick: M(() => y(), ["stop"]) }
        }),
        u(mt, ct(F.$attrs, {
          "model-value": n.value,
          fullscreen: "",
          class: "subject-select",
          "onUpdate:modelValue": w[1] || (w[1] = (L) => v("update:modelValue", L))
        }), {
          default: f(() => [
            n.value ? (C(), E(dt, {
              key: 0,
              class: "subject-select__card"
            }, {
              default: f(() => [
                u(Ke, {
                  class: "subject-select__toolbar system-border-b",
                  onOnCancel: a
                }, {
                  default: f(() => [
                    K(F.$slots, "title", {}, () => [
                      j(D(_(m)(F.dialogTitleT)), 1)
                    ])
                  ]),
                  _: 3
                }),
                u(Ea, {
                  density: "compact",
                  color: "transparent",
                  height: 46,
                  elevation: "0",
                  class: "system-border-b subject-select__second-bar"
                }, {
                  default: f(() => [
                    K(F.$slots, "second-bar", {}, () => [
                      z("div", yo, [
                        z("div", ho, [
                          z("div", Co, [
                            u(G, {
                              icon: "",
                              width: 30,
                              height: 30,
                              onClick: s
                            }, {
                              default: f(() => [
                                u(ye, {
                                  icon: "mdi-tune",
                                  size: 16
                                }),
                                u(Fe, {
                                  activator: "parent",
                                  location: "bottom"
                                }, {
                                  default: f(() => [
                                    j(D(_(m)("common.subjectSelect.filter.toggle")), 1)
                                  ]),
                                  _: 1
                                })
                              ]),
                              _: 1
                            }),
                            K(F.$slots, "second-bar-left")
                          ]),
                          z("div", ko, [
                            K(F.$slots, "second-bar-right")
                          ])
                        ])
                      ])
                    ])
                  ]),
                  _: 3
                }),
                z("div", {
                  class: Be(["subject-select__main", { "subject-select__main--sidebar-active": p.value }])
                }, [
                  z("div", _o, [
                    z("div", wo, [
                      K(F.$slots, "filter")
                    ])
                  ]),
                  z("div", Ao, [
                    K(F.$slots, "content"),
                    F.paginationMode === "more" ? (C(), I("div", Fo, [
                      Et((C(), E(x, {
                        loading: F.loading,
                        size: "small",
                        onClick: g
                      }, {
                        default: f(() => [
                          K(F.$slots, "button-confirm-title", {}, () => [
                            j(D(_(m)("common.button.loadMore")), 1)
                          ])
                        ]),
                        _: 3
                      }, 8, ["loading"])), [
                        [Vt, R.value || F.loading],
                        [
                          Va,
                          k,
                          void 0,
                          { quiet: !0 }
                        ]
                      ])
                    ])) : (C(), E(fo, {
                      key: 1,
                      modelValue: e.value,
                      "onUpdate:modelValue": w[0] || (w[0] = (L) => e.value = L),
                      onChange: l
                    }, null, 8, ["modelValue"]))
                  ])
                ], 2),
                z("div", To, [
                  F.minCount === F.maxCount ? (C(), I("div", Bo, D(_(m)("common.subjectSelect.texts.pickExactCount", { count: F.minCount, selected: i.value })), 1)) : (C(), I("div", Po, D(_(m)("common.subjectSelect.texts.pickRangeCount", {
                    minCount: F.minCount,
                    maxCount: F.maxCount,
                    selected: i.value
                  })), 1)),
                  u(ft),
                  u($, {
                    disabled: r.value,
                    onClick: M(h, ["stop"])
                  }, {
                    default: f(() => [
                      K(F.$slots, "button-confirm-title", {}, () => [
                        j(D(_(m)("common.button.confirm")), 1)
                      ])
                    ]),
                    _: 3
                  }, 8, ["disabled"])
                ])
              ]),
              _: 3
            })) : W("", !0)
          ]),
          _: 3
        }, 16, ["model-value"])
      ], 64);
    };
  }
});
export {
  os as ADatatableOrdering,
  fo as ADatatablePagination,
  ds as AFilterBooleanSelect,
  ms as AFilterDatetimePicker,
  fs as AFilterInteger,
  vs as AFilterRemoteAutocomplete,
  ps as AFilterRemoteAutocompleteWithMinimal,
  gs as AFilterString,
  es as AFilterTimeInterval,
  ts as AFilterValueObjectOptionsSelect,
  as as AFilterWrapper,
  bs as AFilterWrapperSubjectSelect,
  ys as AFormRemoteAutocomplete,
  is as ASubjectSelect,
  Re as DatatablePaginationKey,
  he as FilterConfigKey,
  Ce as FilterDataKey,
  hs as FilterInnerConfigKey,
  Cs as FilterInnerDataKey,
  Le as TimeIntervalSpecialOptions,
  ce as UserAdminConfigLayoutType,
  Na as UserAdminConfigLayoutTypeDefault,
  Ie as UserAdminConfigType,
  ja as UserAdminConfigTypeDefault,
  bo as createDatatableColumnsConfig,
  Xt as createFilter,
  Gt as createFilterStore,
  ze as generateListQuery,
  ss as useApiFetchByIds,
  St as useApiFetchList,
  ns as useApiFetchListBatch,
  ia as useApiQueryBuilder,
  ke as useApiRequest,
  ut as useFilterHelpers,
  ls as useJobApi,
  Ve as usePagination,
  rs as useSubjectSelect,
  Lt as useUserAdminConfigApi,
  Ma as useUserAdminConfigFactory
};
//# sourceMappingURL=labs.js.map
