import { reactive as q, onUnmounted as D, defineComponent as R, ref as j, computed as A, resolveComponent as C, openBlock as n, createElementBlock as c, Fragment as v, createElementVNode as b, normalizeClass as B, unref as _, createTextVNode as X, toDisplayString as V, renderSlot as T, createCommentVNode as y, createBlock as r, renderList as N, withCtx as f, createVNode as k, Teleport as U } from "vue";
import { useBreakpoints as Y } from "@feedmepos/ui-library";
import { F as $ } from "./FmAdminBadge-DjnBAgyv.js";
import { useI18n as G, useCoreStore as J } from "@feedmepos/mf-common";
const F = q({});
function K() {
  const x = `${Math.random()}`, g = new ResizeObserver((d) => {
    const u = d.map((s) => s.target.scrollHeight).reduce((s, l) => s + l);
    F[x] = u;
  }), h = (d) => {
    const u = d.el;
    u && g.observe(u);
  }, i = (d) => {
    const u = d.el;
    u && g.unobserve(u);
  };
  return D(() => {
    g.disconnect(), delete F[x];
  }), {
    get tableHeight() {
      return {
        height: `calc(100dvh - ${Object.values(F).reduce((s, l) => s + l, 0) + 80}px)`
      };
    },
    onMounted: h,
    onUnmounted: i
  };
}
const Q = {
  key: 0,
  class: /* @__PURE__ */ B(["text-fm-color-typo-secondary fm-typo-en-body-sm-400"])
}, W = { class: "bg-white flex-1" }, Z = { class: "fixed bottom-96 right-16" }, M = 3, ae = /* @__PURE__ */ R({
  __name: "SingleColumnLayout",
  props: {
    actions: { default: () => [] },
    title: { default: "Title" },
    description: {},
    showBackButton: { type: Boolean },
    defaultPadding: { type: Boolean },
    breadcrumbs: { default: () => [] },
    helperText: {}
  },
  emits: ["click:action"],
  setup(x, { emit: g }) {
    const h = x, i = g, { t: d } = G(), u = J(), s = j(!1), l = A(() => h.actions.find((o) => o.isPrimary)), m = A(() => h.actions.filter((o) => !o.isPrimary)), H = A(
      () => m.value.filter((o) => {
        var a;
        return o.isAdminOnly ?? !1 ? (a = u.sessionUser.value) == null ? void 0 : a.role.isAdmin : !0;
      }).map(
        (o) => ({
          label: `${o.label} ${o.isAdminOnly == !0 ? "(Admin only)" : ""}`,
          value: o.value
        })
      )
    ), { breakpoints: O } = Y(), p = A(() => O.value.xs || O.value.sm), S = K();
    return (o, t) => {
      var w;
      const a = C("FmButton"), E = C("FmMenuItem"), L = C("FmMenu"), z = C("FmCollapsibleTabs"), P = C("FmBottomSheet");
      return n(), c(v, null, [
        b("div", {
          class: B([
            "flex flex-col w-full bg-white h-full",
            {
              "gap-12": p.value
            }
          ])
        }, [
          b("div", {
            onVnodeMounted: t[3] || (t[3] = //@ts-ignore
            (...e) => _(S).onMounted && _(S).onMounted(...e)),
            class: B([
              "flex gap-8 items-center",
              {
                "p-12 border-b-[1px] border-b-fm-color-neutral-gray-100": p.value,
                "px-24 py-16": !p.value
              }
            ])
          }, [
            b("div", {
              class: B([
                "flex-1 flex flex-col gap-4 fm-typo-en-title-md-600 bg-white",
                {
                  "py-12": p.value
                }
              ])
            }, [
              b("div", null, [
                X(V(o.title) + " ", 1),
                T(o.$slots, "headerInfo")
              ]),
              o.helperText ? (n(), c("div", Q, V(o.helperText), 1)) : y("", !0)
            ], 2),
            p.value ? (n(), c(v, { key: 0 }, [
              m.value.length ? (n(), r(a, {
                key: 0,
                variant: "tertiary",
                "prepend-icon": "more_vert",
                onClick: t[0] || (t[0] = (e) => s.value = !0)
              })) : y("", !0)
            ], 64)) : (n(), c(v, { key: 1 }, [
              (n(!0), c(v, null, N(m.value.slice(0, M), (e) => (n(), c(v, {
                key: e.value
              }, [
                e.isAdminOnly ? (n(), r($, { key: 0 }, {
                  default: f(() => [
                    k(a, {
                      label: e.label,
                      "prepend-icon": e.prependIcon,
                      variant: e.variant,
                      "bg-color": e.variant ? void 0 : "neutral-gray-100",
                      "text-color": e.variant ? void 0 : "neutral-gray-400",
                      onClick: (I) => i("click:action", e.value)
                    }, null, 8, ["label", "prepend-icon", "variant", "bg-color", "text-color", "onClick"])
                  ]),
                  _: 2
                }, 1024)) : (n(), r(a, {
                  key: 1,
                  label: e.label,
                  "prepend-icon": e.prependIcon,
                  variant: e.variant,
                  "bg-color": e.variant ? void 0 : "neutral-gray-100",
                  "text-color": e.variant ? void 0 : "neutral-gray-400",
                  onClick: (I) => i("click:action", e.value)
                }, null, 8, ["label", "prepend-icon", "variant", "bg-color", "text-color", "onClick"]))
              ], 64))), 128)),
              m.value.length > M ? (n(), r(L, { key: 0 }, {
                "menu-button": f(() => [
                  k(a, {
                    label: _(d)("inventory.common.more"),
                    "append-icon": "expand_more",
                    "bg-color": "neutral-gray-100",
                    "text-color": "neutral-gray-400"
                  }, null, 8, ["label"])
                ]),
                default: f(() => [
                  (n(!0), c(v, null, N(m.value.slice(M), (e, I) => (n(), r(E, {
                    key: I,
                    label: e.label,
                    onClick: (ee) => i("click:action", e.value)
                  }, null, 8, ["label", "onClick"]))), 128))
                ]),
                _: 1
              })) : y("", !0),
              (w = l.value) != null && w.isAdminOnly ? (n(), r($, { key: 1 }, {
                default: f(() => [
                  k(a, {
                    label: l.value.label,
                    "prepend-icon": l.value.prependIcon,
                    onClick: t[1] || (t[1] = (e) => i("click:action", l.value.value))
                  }, null, 8, ["label", "prepend-icon"])
                ]),
                _: 1
              })) : l.value ? (n(), r(a, {
                key: 2,
                label: l.value.label,
                "prepend-icon": l.value.prependIcon,
                onClick: t[2] || (t[2] = (e) => i("click:action", l.value.value))
              }, null, 8, ["label", "prepend-icon"])) : y("", !0)
            ], 64))
          ], 2),
          b("div", W, [
            T(o.$slots, "default")
          ])
        ], 2),
        l.value && p.value ? (n(), r(U, {
          key: 0,
          to: "body"
        }, [
          b("div", Z, [
            l.value.isAdminOnly ? (n(), r($, { key: 0 }, {
              default: f(() => [
                k(a, {
                  label: l.value.label,
                  "prepend-icon": l.value.prependIcon,
                  onClick: t[4] || (t[4] = (e) => i("click:action", l.value.value)),
                  variant: "fab"
                }, null, 8, ["label", "prepend-icon"])
              ]),
              _: 1
            })) : (n(), r(a, {
              key: 1,
              label: l.value.label,
              "prepend-icon": l.value.prependIcon,
              onClick: t[5] || (t[5] = (e) => i("click:action", l.value.value)),
              variant: "fab"
            }, null, 8, ["label", "prepend-icon"]))
          ])
        ])) : y("", !0),
        m.value.length ? (n(), r(U, {
          key: 1,
          to: "body"
        }, [
          k(P, {
            "dismiss-away": "",
            "no-header": "",
            modelValue: s.value,
            "onUpdate:modelValue": t[7] || (t[7] = (e) => s.value = e)
          }, {
            default: f(() => [
              k(z, {
                class: "pb-8",
                items: H.value,
                "onUpdate:modelValue": t[6] || (t[6] = (e) => (i("click:action", e), s.value = !1))
              }, null, 8, ["items"])
            ]),
            _: 1
          }, 8, ["modelValue"])
        ])) : y("", !0)
      ], 64);
    };
  }
});
export {
  ae as _,
  K as u
};
