import { defineComponent as G, ref as M, computed as R, onMounted as ie, resolveComponent as $, createElementBlock as V, openBlock as y, createVNode as h, createElementVNode as f, toDisplayString as L, unref as p, Fragment as j, renderList as Q, createBlock as Y, watch as de, withCtx as E, h as T, normalizeClass as re, createCommentVNode as X, createTextVNode as me, mergeProps as $e, normalizeStyle as Ae, renderSlot as Ue, withModifiers as te, onUnmounted as Be } from "vue";
import { D as z } from "./dayjs.min-4uUKJ0sS.js";
import { useRouter as De } from "vue-router";
import { O as Oe, b as Te } from "./app-5fxKLAzS.js";
import { B as Ne, H as Re, G as ve, ad as Ee, a5 as be, A as q, u as _e, I as pe, J as Le } from "./index.vue_vue_type_script_setup_true_lang-BMVa5UfU.js";
import { useI18n as Z, useCoreStore as ge, RestaurantSelector as ye } from "@feedmepos/mf-common";
import { useSnackbar as ce, useDialogChild as ze, useProxiedModel as je, useDialog as ke, FmButtonVariant as fe, components as W } from "@feedmepos/ui-library";
import { _ as He } from "./TextChip.vue_vue_type_script_setup_true_lang-8frWuZFL.js";
import { _ as Ce } from "./app-D-J2cjak.js";
import { a as Ye, w as Je } from "./tooltip-B5BiPMx9.js";
import { u as we } from "./discardConfirm-BHni0LNu.js";
import { _ as xe } from "./_plugin-vue_export-helper-CHgC5LLL.js";
function Se(O) {
  return O ? z(O).format("DD/MM/YY HH:mm") : "-";
}
function Ke(O, S, s) {
  const b = (i, _ = !1) => {
    var d;
    return i === void 0 && !_ ? "-" : ((d = s.find((v) => v.value === (i || null))) == null ? void 0 : d.label) || "-";
  };
  return O.map((i) => {
    var e;
    const _ = (e = S.find(({ _id: k }) => k === i._id)) == null ? void 0 : e.posVersion, d = !!_ && !!Ne.Pos.canUse({ feature: Re.F_FEATURE.enum.taxAndServiceChargeV4, posVersion: _ }), v = b(i.catalogId);
    return {
      ...i,
      _default: v,
      _posTakeaway: i.takeawayCatalog ? b(i.takeawayCatalog) : v,
      _additionalCatalogs: (i.additionalCatalogs || []).map((k) => b(k)),
      _lastUpdate: Se(i.updatedAt),
      _pickup: d ? b(i.pickupCatalog, !0) : "-",
      _canUsePickup: d,
      _posVersion: _ || "-"
    };
  });
}
const qe = {
  key: 0,
  class: "flex items-center justify-center"
}, Ge = {
  key: 1,
  class: "space-y-16"
}, We = { class: "text-fm-color-typo-secondary" }, Qe = { class: "space-y-4" }, Xe = /* @__PURE__ */ G({
  __name: "RevertDialog",
  props: {
    restaurant: {}
  },
  setup(O) {
    const S = O, s = ce(), { custom: b } = ve(s), i = M(!1), _ = M(null);
    async function d() {
      await b(
        async () => {
          var l;
          _.value = await Ee.readMenuById(((l = S.restaurant.revertConfig) == null ? void 0 : l._id) || "");
        },
        { isLoading: i }
      );
    }
    const v = R(() => {
      var l;
      return [
        { label: "Main", value: null },
        ...(((l = _.value) == null ? void 0 : l.modules.catalog) || []).map((n) => ({
          label: n.name,
          value: n._id
        }))
      ];
    }), { t: e } = Z(), k = R(() => {
      var o;
      const l = S.restaurant.revertConfig;
      if (!l) return [];
      const n = Ke(
        [
          {
            ...l,
            catalogId: l.catalogId || null
          }
        ],
        ge().restaurants.value,
        v.value
      )[0];
      return [
        { label: e("menu.revert.labels.restaurant"), value: S.restaurant.name },
        {
          label: e("menu.revert.labels.revert_to"),
          value: Se((o = _.value) == null ? void 0 : o.updatedAt)
        },
        { label: e("menu.revert.labels.default"), value: n._default },
        { label: e("menu.revert.labels.pos_takeaway"), value: n._posTakeaway },
        { label: e("menu.revert.labels.pickup"), value: n._pickup },
        {
          label: e("menu.revert.labels.additional_catalogs"),
          value: n._additionalCatalogs.join(", ")
        }
      ];
    });
    ie(async () => d());
    const { emitData: t } = ze();
    return (l, n) => {
      const o = $("FmCircularProgress");
      return i.value ? (y(), V("div", qe, [
        h(o, { size: "lg" })
      ])) : (y(), V("div", Ge, [
        f("div", We, L(p(e)("menu.revert.description", { name: S.restaurant.name })), 1),
        f("div", Qe, [
          (y(!0), V(j, null, Q(k.value, (r) => (y(), Y(Ye, {
            key: r.label,
            name: r.label,
            value: r.value || "--"
          }, null, 8, ["name", "value"]))), 128))
        ])
      ]));
    };
  }
}), Ze = {
  class: "break-all fm-typo-en-body-lg-400 line-clamp-1"
}, et = {
  class: "flex flex-col"
}, tt = /* @__PURE__ */ G({
  __name: "PublishRestaurantSelector",
  props: {
    restaurants: {
      type: Array,
      required: !0
    }
  },
  emits: ["update:modelValue"],
  setup(O, {
    emit: S
  }) {
    const s = O, b = S, i = M([]), _ = R(() => s.restaurants.map((o) => ({
      label: o.name,
      value: o._id
    }))), d = M(""), v = R(() => {
      const o = Array.isArray(i.value) ? i.value : [], r = o.map((c) => _.value.find((U) => U.value === c)).filter((c) => c !== void 0);
      let u = [];
      return d.value ? (u = _.value.filter((c) => c.label.toLowerCase().includes(d.value.toLowerCase()) && !o.includes(c.value)), [...r, ...u]) : (u = _.value.filter((c) => !o.includes(c.value)), [...r, ...u]);
    }), e = R(() => i.value.length > 0 && i.value.length === v.value.length), k = R(() => i.value.filter((o) => v.value.some((r) => r.value === o))), t = () => {
      const o = i.value.filter((r) => !k.value.includes(r));
      e.value === !0 ? l(o) : l(v.value.map((r) => r.value));
    }, l = (o) => {
      i.value = o;
    };
    de(i, (o) => {
      b("update:modelValue", o);
    });
    function n(o) {
      return s.restaurants.filter((r) => o.includes(r._id)).map((r) => r.name);
    }
    return (o, r) => {
      const u = $("FmSearch"), c = $("FmCheckbox"), U = $("FmSelect");
      return y(), Y(U, {
        modelValue: i.value,
        "onUpdate:modelValue": r[1] || (r[1] = (B) => i.value = B),
        placeholder: "Select Restaurant",
        items: v.value,
        multiselect: !0,
        "hide-chips": !0
      }, {
        default: E(() => [f("p", Ze, L(i.value.length === s.restaurants.length ? "All restaurants" : n(i.value).join(", ")), 1)]),
        "menu-wrapper": E(() => [f("div", et, [h(u, {
          class: "py-8",
          modelValue: d.value,
          "onUpdate:modelValue": r[0] || (r[0] = (B) => d.value = B),
          placeholder: "Search Restaurant"
        }, null, 8, ["modelValue"]), h(c, {
          class: "py-8",
          "model-value": e.value,
          label: "All restaurants",
          value: "1",
          indeterminate: i.value.length > 0,
          "onUpdate:modelValue": t
        }, null, 8, ["model-value", "indeterminate"]), (y(!0), V(j, null, Q(v.value, (B, J) => (y(), V("div", {
          key: J
        }, [h(c, {
          "model-value": i.value,
          label: B.label,
          value: B.value,
          "onUpdate:modelValue": l
        }, null, 8, ["model-value", "label", "value"])]))), 128))])]),
        _: 1
      }, 8, ["modelValue", "items"]);
    };
  }
}), at = {
  class: "flex pb-16 w-full items-center justify-between gap-8 min-w-0"
}, lt = {
  key: 0
}, st = {
  key: 1,
  class: "text-fm-color-neutral-gray-200"
}, nt = /* @__PURE__ */ G({
  __name: "RestaurantPublishDetail",
  props: {
    restaurantPublishStatus: {
      type: Object,
      required: !0
    },
    statusMap: {
      type: Object,
      required: !0
    }
  },
  setup(O) {
    const {
      t: S
    } = Z(), s = O, b = ge(), i = [{
      accessorKey: "restaurantName",
      header: S("menu.publish.scheduler_publish.restaurant_publish_details.table.column.restaurant")
    }, {
      id: "status",
      accessorKey: "publishStatus",
      header: S("menu.publish.scheduler_publish.restaurant_publish_details.table.column.status"),
      cell: ({
        row: l
      }) => {
        const n = l.original.publishStatus, o = Object.values(s.statusMap).find((u) => u.label === n), r = (o == null ? void 0 : o.textColor) ?? "text-fm-color-neutral-gray-300";
        return T("p", {
          class: `${r}`
        }, n);
      }
    }, {
      accessorKey: "publishedAt",
      header: S("menu.publish.scheduler_publish.restaurant_publish_details.table.column.published_at"),
      cell: ({
        row: l
      }) => {
        const n = l.original.publishedAt;
        return T("p", {
          class: "whitespace-nowrap"
        }, n);
      }
    }], _ = M([]), d = R(() => Object.entries(s.statusMap).map(([l, n]) => ({
      label: n.label,
      value: l
    }))), v = M(null), e = R(() => Object.entries(s.restaurantPublishStatus).filter(([l, n]) => _.value.length === 0 ? !0 : _.value.includes(n.status)).filter(([l, n]) => !v.value || v.value.length === 0 ? !0 : v.value.includes(l)).map(([l, n]) => ({
      restaurantName: t(l),
      publishStatus: s.statusMap[n.status].label,
      publishedAt: n.publishedAt ? z(n.publishedAt).format("YYYY-MM-DD HH:mm:ss") : ""
    })).sort((l, n) => l.restaurantName.localeCompare(n.restaurantName))), k = R(() => {
      var n, o;
      const l = {};
      for (const r of b.restaurants.value) {
        if (!(r != null && r._id)) continue;
        const u = (n = r == null ? void 0 : r.profile) == null ? void 0 : n.code, c = (o = r == null ? void 0 : r.profile) == null ? void 0 : o.name;
        l[r._id] = `${u ? u + " - " : ""}${c || "Unknown Restaurant"}`;
      }
      return l;
    });
    function t(l) {
      return k.value[l] ?? "Unknown Restaurant";
    }
    return (l, n) => {
      const o = $("FmSelect"), r = $("FmTable");
      return y(), V(j, null, [f("div", at, [h(p(ye), {
        class: "flex-1 min-w-0",
        multiple: "",
        modelValue: v.value,
        "onUpdate:modelValue": n[0] || (n[0] = (u) => v.value = u)
      }, null, 8, ["modelValue"]), h(o, {
        class: "flex-1 min-w-0",
        modelValue: _.value,
        "onUpdate:modelValue": n[1] || (n[1] = (u) => _.value = u),
        items: d.value,
        multiselect: "",
        "hide-chips": ""
      }, {
        default: E(() => [_.value.length > 0 ? (y(), V("div", lt, L(_.value.map((u) => {
          var c;
          return (c = s.statusMap[u]) == null ? void 0 : c.label;
        }).join(", ")), 1)) : (y(), V("div", st, L(p(S)("menu.publish.scheduler_publish.restaurant_publish_details.select_publish_status")), 1))]),
        _: 1
      }, 8, ["modelValue", "items"])]), h(Ce, null, {
        default: E(() => [e.value.length > 0 ? (y(), Y(r, {
          key: 0,
          class: "flex-1 overflow-hidden",
          "column-defs": i,
          "row-data": e.value,
          "page-size": Object.entries(s.restaurantPublishStatus).length,
          "hide-footer": "",
          "pin-header-row": ""
        }, null, 8, ["row-data", "page-size"])) : (y(), Y(be, {
          key: 1,
          title: "No publish status found",
          subtitle: ""
        }))]),
        _: 1
      })], 64);
    };
  }
}), ot = { class: "fm-calendar__name-row fm-typo-en-body-md-400 text-fm-color-typo-tertiary" }, ut = ["id"], rt = {
  key: 0,
  class: "fm-calendar__cell__button--today"
}, it = ["onClick", "onMouseover"], dt = /* @__PURE__ */ G({
  __name: "FmCalendar",
  props: {
    days: {},
    dayCellClass: { type: [Object, Function], default: void 0 },
    onDayClick: {},
    onCellMouseOver: { type: Function, default: void 0 },
    cellSize: { default: "md" }
  },
  setup(O) {
    const { t: S } = Z(), s = () => [
      S("menu.publish.scheduler.calender.day.sun"),
      S("menu.publish.scheduler.calender.day.mon"),
      S("menu.publish.scheduler.calender.day.tue"),
      S("menu.publish.scheduler.calender.day.wed"),
      S("menu.publish.scheduler.calender.day.thu"),
      S("menu.publish.scheduler.calender.day.fri"),
      S("menu.publish.scheduler.calender.day.sat")
    ], b = z(), i = (d, v) => typeof d == "function" ? d(...v) : d, _ = (d, v) => {
      if (!v) return;
      const e = {
        "fm-calendar__cell--selected": !1,
        "fm-calendar__cell--selected-start": !1,
        "fm-calendar__cell--selected-end": !1,
        "fm-calendar__cell--selected-between": !1
      };
      let k;
      if (typeof v == "function") {
        const { status: t, className: l } = v(d);
        t && (e["fm-calendar__cell--selected"] = t.isSelected ?? !1, e["fm-calendar__cell--selected-start"] = t.isStart ?? !1, e["fm-calendar__cell--selected-end"] = t.isEnd ?? !1, e["fm-calendar__cell--selected-between"] = t.isBetween ?? !1), k = l ?? "";
      } else {
        const { status: t, className: l } = v;
        t && (e["fm-calendar__cell--selected"] = i(t.isSelected, [d]) ?? !1, e["fm-calendar__cell--selected-start"] = i(t.isStart, [d]) ?? !1, e["fm-calendar__cell--selected-end"] = i(t.isEnd, [d]) ?? !1, e["fm-calendar__cell--selected-between"] = i(t.isBetween, [d]) ?? !1), k = i(l, [d]) ?? "";
      }
      return [e, k];
    };
    return (d, v) => (y(), V("div", null, [
      f("div", ot, [
        (y(!0), V(j, null, Q(s(), (e) => (y(), V("div", {
          key: e,
          class: re(["fm-calendar__cell", `fm-calendar__cell__${d.cellSize}`])
        }, L(e), 3))), 128))
      ]),
      f("div", null, [
        (y(!0), V(j, null, Q(d.days, (e, k) => (y(), V("div", {
          key: k,
          class: "fm-calendar__row fm-typo-en-body-md-400"
        }, [
          (y(!0), V(j, null, Q(e, (t) => (y(), V("div", {
            id: `${t.date.toISOString()}`,
            key: t.date.date(),
            class: re(["fm-calendar__cell", [
              `fm-calendar__cell__${d.cellSize}`,
              _(t.date, d.dayCellClass),
              !t.isCurrentMonth && "fm-calendar__cell--not-current-month"
            ]])
          }, [
            t.date.isSame(p(b), "day") && t.isCurrentMonth ? (y(), V("div", rt)) : X("", !0),
            t.isCurrentMonth ? (y(), V("button", {
              key: 1,
              class: "fm-calendar__cell__button",
              type: "button",
              onClick: (l) => d.onDayClick(t),
              onMouseover: (l) => {
                var n;
                return (n = d.onCellMouseOver) == null ? void 0 : n.call(d, t.date);
              }
            }, L(t.date.date()), 41, it)) : X("", !0)
          ], 10, ut))), 128))
        ]))), 128))
      ])
    ]));
  }
}), he = /* @__PURE__ */ xe(dt, [["__scopeId", "data-v-47484312"]]), ct = { class: "fm-typo-en-body-md-600" }, mt = {
  id: "in-calendar-app",
  class: "h-[264px] overflow-y-auto w-[160px]"
}, pt = ["onVnodeMounted"], ft = ["onVnodeMounted"], ae = /* @__PURE__ */ G({
  __name: "FmDateRangeYearMonthPicker",
  props: {
    modelValue: {},
    picker: {},
    min: {},
    max: {}
  },
  emits: ["update:modelValue"],
  setup(O, { emit: S }) {
    const { t: s } = Z(), b = O, i = S, _ = M(!1), d = R(() => {
      const t = z(b.min).startOf("year"), l = z(b.max).startOf("year"), n = l.diff(t, "year"), o = [];
      for (let r = 0; r <= n; r++)
        o.push(l.subtract(r, "year"));
      return o;
    }), v = (t) => {
      const l = z(b.min).startOf("month"), n = z(b.max).startOf("month");
      return t.get("year") === l.get("year") ? t.startOf("month").isAfter(l) || t.get("month") === l.get("month") : t.get("year") === n.get("year") ? t.startOf("month").isBefore(n) || t.get("month") === n.get("month") : !0;
    }, e = (t) => {
      const l = z(b.min).startOf("month"), n = z(b.max).startOf("month");
      if (l.get("year") === t.get("year")) {
        i("update:modelValue", l);
        return;
      }
      if (n.get("year") === t.get("year")) {
        i("update:modelValue", n);
        return;
      }
      i("update:modelValue", t);
    };
    function k(t, l) {
      if (!l)
        return !1;
      const n = t.el, o = n == null ? void 0 : n.parentElement;
      !n || !o || o.scrollTo({
        top: n.offsetTop - 50
      });
    }
    return (t, l) => {
      const n = $("FmIcon"), o = $("FmMenuItem"), r = $("FmMenu");
      return y(), Y(r, {
        trigger: "click",
        onMenuChanged: l[0] || (l[0] = (u) => _.value = u)
      }, {
        "menu-button": E(() => [
          f("div", {
            class: re(["flex gap-4 h-24 items-center px-4 rounded-sm", _.value ? "text-fm-color-primary" : "hover:bg-fm-color-neutral-gray-100"])
          }, [
            f("div", ct, [
              t.picker === "month" ? (y(), V(j, { key: 0 }, [
                me(L(t.modelValue.format(p(s)("menu.publish.scheduler.date.monthFormat"))), 1)
              ], 64)) : X("", !0),
              t.picker === "year" ? (y(), V(j, { key: 1 }, [
                me(L(t.modelValue.format(p(s)("menu.publish.scheduler.date.yearFormat"))), 1)
              ], 64)) : X("", !0)
            ]),
            h(n, {
              name: _.value ? "expand_less" : "expand_more",
              size: "md",
              color: "black"
            }, null, 8, ["name"])
          ], 2)
        ]),
        default: E(() => [
          f("ul", mt, [
            t.picker === "month" ? (y(!0), V(j, { key: 0 }, Q(Array.from(Array(12), (u, c) => t.modelValue.month(c)), (u) => (y(), V("li", {
              key: u.format(p(s)("menu.publish.scheduler.date.monthFormat")),
              onVnodeMounted: (c) => k(
                c,
                t.modelValue.format(p(s)("menu.publish.scheduler.date.monthFormat")) === u.format(p(s)("menu.publish.scheduler.date.monthFormat"))
              )
            }, [
              h(o, {
                disabled: !v(u),
                "model-value": t.modelValue.format(p(s)("menu.publish.scheduler.date.monthFormat")) === u.format(p(s)("menu.publish.scheduler.date.monthFormat")),
                label: u.format(p(s)("menu.publish.scheduler.date.monthFormat")),
                "onUpdate:modelValue": (c) => i("update:modelValue", u)
              }, null, 8, ["disabled", "model-value", "label", "onUpdate:modelValue"])
            ], 8, pt))), 128)) : X("", !0),
            t.picker === "year" ? (y(!0), V(j, { key: 1 }, Q(d.value, (u) => (y(), V("li", {
              key: u.format(p(s)("menu.publish.scheduler.date.yearFormat")),
              onVnodeMounted: (c) => k(
                c,
                t.modelValue.format(p(s)("menu.publish.scheduler.date.yearFormat")) === u.format(p(s)("menu.publish.scheduler.date.yearFormat"))
              )
            }, [
              h(o, {
                "model-value": t.modelValue.format(p(s)("menu.publish.scheduler.date.yearFormat")) === u.format(p(s)("menu.publish.scheduler.date.yearFormat")),
                label: u.format(p(s)("menu.publish.scheduler.date.yearFormat")),
                "onUpdate:modelValue": (c) => e(u)
              }, null, 8, ["model-value", "label", "onUpdate:modelValue"])
            ], 8, ft))), 128)) : X("", !0)
          ])
        ]),
        _: 1
      });
    };
  }
}), ht = { class: "p-12 space-y-4 w-[552px]" }, vt = { class: "w-max" }, bt = { class: "flex space-x-24" }, _t = { class: "flex items-center py-8 space-x-16" }, gt = { class: "flex space-x-4" }, yt = { class: "flex items-center justify-end py-8 space-x-16" }, kt = { class: "flex space-x-4" }, Ct = { class: "flex gap-8 items-center justify-end w-full" }, le = "YYYY-MM-DD", wt = /* @__PURE__ */ G({
  __name: "DateTimePicker",
  props: {
    modelValue: {},
    showValidBorder: { type: Boolean, default: !1 },
    min: { default: () => z().subtract(50, "year").format(le) },
    max: { default: () => z().add(25, "year").format(le) },
    zIndex: { default: void 0 },
    label: { default: "" },
    labelMark: { default: "none" },
    labelInfo: { default: "" },
    disabled: { type: Boolean, default: void 0 },
    focused: { type: Boolean, default: !1 },
    rules: { default: () => [] },
    helperText: { default: "" },
    helperState: { default: "none" }
  },
  emits: ["update:schedulerTime"],
  setup(O, { emit: S }) {
    const { t: s } = Z(), b = O, i = S, _ = je(b, "modelValue"), d = M({
      hours: new Date(_.value).getHours() % 12 || 12,
      minutes: new Date(_.value).getMinutes(),
      period: new Date(_.value).getHours() >= 12 ? "PM" : "AM"
      /* AM */
    }), v = M(z(_.value, le)), e = M(!1);
    function k(w, x) {
      const [m, g, F] = w.split("-").map(Number), D = new Date(m, g - 1, F);
      let I = x.hours % 12;
      return x.period === "PM" && (I += 12), D.setHours(I), D.setMinutes(x.minutes), D.setSeconds(0), D.setMilliseconds(0), D;
    }
    const t = () => {
      _.value = v.value.format(le);
      const w = k(_.value, d.value);
      i("update:schedulerTime", w.toISOString()), setTimeout(() => {
        e.value = !1;
      }, 0);
    }, l = () => {
      v.value = _.value ? z(_.value) : null, e.value = !1;
    }, n = (w) => {
      e.value = w, w || l();
    }, o = M(z().startOf("month")), r = M(z().startOf("month").add(1, "month")), u = (w, x) => {
      w === "left" ? (o.value = x, r.value = x.add(1, "month")) : w === "right" && (r.value = x, o.value = x.subtract(1, "month"));
    }, c = R(() => B(o.value)), U = R(() => B(o.value.add(1, "month"))), B = (w) => {
      const x = [], m = w.endOf("month"), g = w.month();
      let F = w.startOf("week"), D = [];
      for (; F.isBefore(m.endOf("week")); )
        F.day() === 0 && D.length > 0 && (x.push(D), D = []), D.push({
          date: F,
          isCurrentMonth: F.month() === g
        }), F = F.add(1, "day");
      return D.length > 0 && x.push(D), x.length < 6 && x.push([]), x;
    }, J = (w) => {
      v.value = w;
    };
    return (w, x) => {
      const m = $("FmIcon"), g = $("FmTimeInput"), F = $("FmButton"), D = $("FmPopover");
      return y(), Y(D, {
        "show-popover": e.value,
        "z-index": b.zIndex,
        "exclude-el-from-click-outside": ["in-calendar-app"],
        onPopoverChanged: n
      }, {
        "popover-button": E(() => [
          f("div", $e({
            opened: e.value,
            showValidBorder: w.showValidBorder
          }, { class: "text-fm-color-primary" }), " Select Date & Time ", 16)
        ]),
        default: E(() => [
          f("div", ht, [
            f("div", vt, [
              f("div", bt, [
                f("div", null, [
                  f("div", _t, [
                    h(m, {
                      outline: !1,
                      class: "cursor-pointer select-none",
                      color: "#1C1C1E",
                      name: "chevron_left",
                      size: "md",
                      onClick: x[0] || (x[0] = () => u("left", o.value.subtract(1, "month")))
                    }),
                    f("div", gt, [
                      h(ae, {
                        max: w.max,
                        min: w.min,
                        "model-value": o.value,
                        picker: "month",
                        "onUpdate:modelValue": x[1] || (x[1] = (I) => u("left", I))
                      }, null, 8, ["max", "min", "model-value"]),
                      h(ae, {
                        max: w.max,
                        min: w.min,
                        "model-value": o.value,
                        picker: "year",
                        "onUpdate:modelValue": x[2] || (x[2] = (I) => u("left", I))
                      }, null, 8, ["max", "min", "model-value"])
                    ])
                  ]),
                  h(he, {
                    "day-cell-class": {
                      status: {
                        isSelected: (I) => I.isSame(v.value, "date")
                      }
                    },
                    days: c.value,
                    "on-day-click": (I) => J(I.date)
                  }, null, 8, ["day-cell-class", "days", "on-day-click"])
                ]),
                f("div", null, [
                  f("div", yt, [
                    f("div", kt, [
                      h(ae, {
                        max: w.max,
                        min: w.min,
                        "model-value": r.value,
                        picker: "month",
                        "onUpdate:modelValue": x[3] || (x[3] = (I) => u("right", I))
                      }, null, 8, ["max", "min", "model-value"]),
                      h(ae, {
                        max: w.max,
                        min: w.min,
                        "model-value": r.value,
                        picker: "year",
                        "onUpdate:modelValue": x[4] || (x[4] = (I) => u("right", I))
                      }, null, 8, ["max", "min", "model-value"])
                    ]),
                    h(m, {
                      outline: !1,
                      class: "cursor-pointer select-none",
                      color: "#1C1C1E",
                      name: "chevron_right",
                      size: "md",
                      onClick: x[5] || (x[5] = () => u("left", o.value.add(1, "month")))
                    })
                  ]),
                  h(he, {
                    "day-cell-class": {
                      status: {
                        isSelected: (I) => I.isSame(v.value, "date")
                      }
                    },
                    days: U.value,
                    "on-day-click": (I) => J(I.date)
                  }, null, 8, ["day-cell-class", "days", "on-day-click"])
                ])
              ])
            ]),
            h(g, {
              "model-value": d.value ?? {
                hours: 0,
                minutes: 0,
                period: "AM"
                /* AM */
              },
              "onUpdate:modelValue": x[6] || (x[6] = (I) => d.value = I)
            }, null, 8, ["model-value"]),
            f("div", Ct, [
              h(F, {
                label: p(s)("common.cancel"),
                size: "md",
                variant: "tertiary",
                onClick: l
              }, null, 8, ["label"]),
              h(F, {
                disabled: !v.value,
                label: p(s)("common.confirm"),
                size: "md",
                variant: "primary",
                onClick: t
              }, null, 8, ["disabled", "label"])
            ])
          ])
        ]),
        _: 1
      }, 8, ["show-popover", "z-index"]);
    };
  }
}), xt = { class: "container" }, St = /* @__PURE__ */ G({
  __name: "ProgressBar",
  props: {
    bgcolor: {},
    completed: {}
  },
  setup(O) {
    const S = O, s = R(() => ({
      height: "100%",
      width: `${S.completed ?? 0}%`,
      backgroundColor: S.bgcolor,
      transition: "width 1s ease-in-out",
      borderRadius: "inherit",
      textAlign: "right"
    }));
    return (b, i) => (y(), V("div", xt, [
      f("div", {
        style: Ae(s.value)
      }, null, 4)
    ]));
  }
}), Ft = /* @__PURE__ */ xe(St, [["__scopeId", "data-v-709d7500"]]), Vt = {
  class: "flex items-center gap-24"
}, It = {
  class: "fm-typo-en-title-md-600"
}, Pt = /* @__PURE__ */ G({
  __name: "PublishProgressView",
  props: {
    progress: {
      type: Number,
      required: !1
    },
    restaurants: {
      type: Array,
      required: !0
    }
  },
  emits: ["publishMenu"],
  setup(O, {
    expose: S,
    emit: s
  }) {
    const {
      t: b
    } = Z(), i = ce(), _ = ke(), d = O, v = {
      [q.F_PUBLISH_JOB_STATUS.Enum.PENDING]: {
        label: b("menu.publish.scheduler_publish.status.pending"),
        textColor: "text-fm-color-neutral-gray-300",
        backgroundColor: "#E0E0DE"
      },
      [q.F_PUBLISH_JOB_STATUS.Enum.RUNNING]: {
        label: b("menu.publish.scheduler_publish.status.running"),
        textColor: "text-fm-color-system-warning-300",
        backgroundColor: "#FFB800"
      },
      [q.F_PUBLISH_JOB_STATUS.Enum.COMPLETED]: {
        label: b("menu.publish.scheduler_publish.status.completed"),
        textColor: "text-fm-color-system-success-300",
        backgroundColor: "#34C759"
      },
      [q.F_PUBLISH_JOB_STATUS.Enum.FAILED]: {
        label: b("menu.publish.scheduler_publish.status.failed"),
        textColor: "text-fm-color-system-error-300",
        backgroundColor: "#FF3B30"
      }
    }, e = _e(), k = M(!1), t = (m) => {
      typeof m == "boolean" ? k.value = m : k.value = !k.value;
    };
    S({
      show: k,
      trigger: t
    });
    const l = s, n = R(() => e.state.nextSchedulerPublish ?? {}), o = R(() => Object.entries(n.value).map(([g, F]) => {
      var N;
      const D = e.runningPublishJob, I = Object.keys(F.restaurants || {}).length;
      return {
        date: g,
        publisher: ((N = F.owner) == null ? void 0 : N.name) ?? "Unknown",
        total_restaurants: `${I} restaurants`,
        selectedRestaurantIds: Object.keys(F.restaurants || {}),
        restaurantPublishStatus: F.restaurants || {},
        status: F.status,
        progress: D === g ? d.progress ?? 0 : 0
        // Only apply progress to the running job's row
      };
    })), r = M([]), u = M(null), c = M(null), U = [{
      accessorKey: "date",
      header: "Date",
      cell: ({
        row: m
      }) => {
        if (m.original.date === "new") {
          if (u.value !== null)
            return new Date(u.value).toLocaleString();
          const F = z(Date.now()).toISOString();
          return T(wt, {
            class: "flex h-full items-center",
            modelValue: F,
            "onUpdate:schedulerTime": (D) => {
              u.value = D;
            }
          });
        }
        return new Date(m.original.date).toLocaleString();
      }
    }, {
      accessorKey: "publisher",
      header: "Publisher Name"
    }, {
      accessorKey: "total_restaurants",
      header: "Total restaurants",
      cell: ({
        row: m
      }) => m.original.date === "new" ? T(tt, {
        restaurants: d.restaurants,
        "onUpdate:modelValue": (F) => {
          r.value = F;
        }
      }) : T("div", {
        class: "flex items-center justify-between"
      }, [T("p", {}, m.original.total_restaurants), T(W.FmMenu, {}, {
        "menu-button": () => T(W.FmIcon, {
          name: "info",
          class: "text-fm-color-neutral-gray-300 cursor-pointer"
        }),
        default: () => x(m.original.selectedRestaurantIds).map((F) => T(W.FmMenuItem, {
          key: F,
          label: F
        }))
      })])
    }, {
      accessorKey: "progress",
      header: "Progress",
      cell: ({
        row: m
      }) => {
        const g = m.original.status;
        return m.original.date === "new" ? T("div", {
          class: "flex justify-end items-center gap-8"
        }, [T(W.FmButton, {
          variant: "tertiary",
          prependIcon: "close",
          textColor: "system-error-300",
          onClick: () => {
            u.value = null, B.value = null, c.value = null;
          }
        }), T(W.FmButton, {
          variant: "tertiary",
          prependIcon: "check",
          textColor: "system-success-300",
          onClick: async () => {
            if (!u.value || r.value.length === 0) {
              c.value = !1, i.open({
                type: "error",
                message: "Please select date and restaurants to schedule publish."
              });
              return;
            } else
              c.value = !0;
          }
        })]) : T("div", {
          class: "flex justify-between items-center gap-32"
        }, [T("div", {
          class: "flex flex-col w-full gap-4"
        }, [T("div", {
          class: "flex items-center gap-8"
        }, [T("p", {
          class: `fm-typo-en-body-md-400 ${v[g].textColor}`
        }, v[g].label), ...g === q.F_PUBLISH_JOB_STATUS.Enum.RUNNING ? [T("p", {
          class: `fm-typo-en-body-md-400 ${v[g].textColor}`
        }, `(${m.original.progress}/${m.original.total_restaurants})`)] : []]), T(Ft, {
          bgcolor: v[g].backgroundColor,
          completed: g === q.F_PUBLISH_JOB_STATUS.Enum.PENDING ? 0 : g === q.F_PUBLISH_JOB_STATUS.Enum.RUNNING ? Math.floor((m.original.progress ?? 0) / parseInt(m.original.total_restaurants) * 100) : (g === q.F_PUBLISH_JOB_STATUS.Enum.COMPLETED, 100)
        })]), T(W.FmButton, {
          variant: "plain",
          prependIcon: "info",
          disabled: Array.isArray(m.original.restaurantPublishStatus),
          onClick: () => {
            _.open({
              title: b("menu.publish.scheduler_publish.restaurant_publish_details.title"),
              contentComponent: nt,
              contentComponentProps: {
                restaurantPublishStatus: m.original.restaurantPublishStatus,
                statusMap: v
              },
              contentClass: "flex flex-col h-full"
            });
          }
        }), T(W.FmButton, {
          variant: "tertiary",
          prependIcon: "delete",
          disabled: g !== q.F_PUBLISH_JOB_STATUS.Enum.PENDING,
          textColor: "system-error-300",
          onClick: () => {
            const D = z(m.original.date).toISOString();
            _.open({
              title: "Confirm Remove",
              message: "Are you sure you want to remove this scheduled publish? This action cannot be undone.",
              primaryActions: {
                text: "Remove",
                close: !1
              },
              secondaryActions: {
                text: "Cancel",
                close: !0
              }
            }).onPrimary(() => {
              e.deleteSchedulerPublish(D).then(() => {
                i.open({
                  type: "success",
                  message: "Scheduled publish deleted successfully."
                });
              }).catch(() => {
                i.open({
                  type: "error",
                  message: "Failed to delete scheduled publish. Please try again."
                });
              }).finally(() => {
                _.close();
              });
            });
          }
        })]);
      }
    }];
    ie(async () => {
      await e.getNextSchedulerPublish();
    });
    const B = M(null);
    function J() {
      c.value = !1, B.value = {
        date: "new",
        restaurantsIds: []
      };
    }
    de(c, async (m) => {
      m && (l("publishMenu", {
        schedulerTime: u.value,
        restaurantIds: r.value
      }), await e.getNextSchedulerPublish(), u.value = null, r.value = [], c.value = !1, B.value = null, c.value = null);
    });
    const w = we(() => c.value !== null && c.value === !1, () => {
      k.value = !1, B.value = null, u.value = null, r.value = [], c.value = null;
    });
    function x(m) {
      return d.restaurants.filter((g) => m.includes(g._id)).map((g) => g.name);
    }
    return (m, g) => {
      const F = $("FmButton"), D = $("FmTable"), I = $("FmSideSheet");
      return y(), V(j, null, [Ue(m.$slots, "default", {
        trigger: t
      }), h(I, {
        modelValue: k.value,
        "onUpdate:modelValue": g[1] || (g[1] = (N) => k.value = N),
        "close-button": !1,
        "max-width": 800,
        "onOn:clickedAway": p(w)
      }, {
        "side-sheet-header": E(() => [f("div", Vt, [h(F, {
          variant: p(fe).Tertiary,
          "prepend-icon": "arrow_back",
          onClick: te(p(w), ["stop"])
        }, null, 8, ["variant", "onClick"]), f("p", It, L(p(b)("menu.publish.actions.publish_progress")), 1)])]),
        default: E(() => [f("div", null, [h(D, {
          class: "pb-8",
          "row-data": [...o.value, B.value].filter(Boolean),
          "column-defs": U,
          "shrink-at": !1,
          pageSize: o.value.length + (B.value ? 1 : 0),
          "hide-footer": ""
        }, null, 8, ["row-data", "pageSize"]), p(e).state.featureFlags.schedulerPublish && !B.value ? (y(), Y(F, {
          key: 0,
          variant: p(fe).Plain,
          "prepend-icon": "add",
          label: p(b)("menu.publish.actions.add_scheduler_publish"),
          onClick: g[0] || (g[0] = () => J())
        }, null, 8, ["variant", "label"])) : X("", !0)])]),
        _: 1
      }, 8, ["modelValue", "onOn:clickedAway"])], 64);
    };
  }
}), Mt = { class: "fm-typo-en-title-md-600" }, $t = { class: "mt-40" }, At = { class: "fm-typo-en-title-sm-600" }, Ut = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary mt-4 mb-8" }, Bt = { class: "flex gap-8 items-center justify-start" }, Dt = /* @__PURE__ */ G({
  __name: "UpdateCatalogDialog",
  props: {
    catalogs: {
      type: Array,
      required: !0
    }
  },
  emits: ["onComplete"],
  setup(O, { expose: S, emit: s }) {
    const { t: b } = Z(), i = O;
    S({
      show: n,
      hide: o
    });
    const _ = s;
    function d() {
      return {
        restaurantId: "",
        catalogId: void 0,
        takeawayCatalog: void 0,
        pickupCatalog: null,
        additionalCatalogs: []
      };
    }
    const v = R(() => [
      {
        label: b("menu.publish.update_catalog_dialog.sections.default.use_default"),
        value: null
      },
      ...i.catalogs.map((c) => ({
        label: c.name,
        value: c._id
      }))
    ]), e = R(() => [
      {
        label: b("menu.publish.update_catalog_dialog.sections.default.use_default"),
        value: null
      },
      ...i.catalogs.map((c) => ({
        label: c.name,
        value: c._id
      }))
    ]), k = M(d()), t = M(!1), l = M(void 0);
    function n(c) {
      l.value = c ? pe(c) : d(), k.value = pe(l.value), t.value = !0;
    }
    function o() {
      t.value = !1;
    }
    const r = we(
      () => !Le.isEqual(l.value, k.value),
      () => {
        o();
      }
    );
    function u() {
      o(), _("onComplete", k.value);
    }
    return (c, U) => {
      const B = $("FmSelect"), J = $("FmCheckbox"), w = $("FmButton"), x = $("FmSideSheet");
      return y(), Y(x, {
        modelValue: t.value,
        "onUpdate:modelValue": U[5] || (U[5] = (m) => t.value = m),
        "max-width": 560,
        "onOn:clickedAway": p(r)
      }, {
        "side-sheet-header": E(() => [
          f("span", Mt, L(p(b)("menu.publish.update_catalog_dialog.title")), 1)
        ]),
        "side-sheet-footer": E(() => [
          f("div", Bt, [
            h(w, {
              label: p(b)("menu.publish.update_catalog_dialog.actions.update"),
              size: "lg",
              variant: "primary",
              onClick: U[4] || (U[4] = () => u())
            }, null, 8, ["label"]),
            h(w, {
              label: p(b)("menu.publish.update_catalog_dialog.actions.cancel"),
              size: "lg",
              variant: "tertiary",
              onClick: o
            }, null, 8, ["label"])
          ])
        ]),
        default: E(() => [
          h(B, {
            modelValue: k.value.catalogId,
            "onUpdate:modelValue": U[0] || (U[0] = (m) => k.value.catalogId = m),
            items: v.value,
            class: "mb-24",
            label: p(b)("menu.publish.update_catalog_dialog.sections.default.label")
          }, null, 8, ["modelValue", "items", "label"]),
          h(B, {
            modelValue: k.value.takeawayCatalog,
            "onUpdate:modelValue": U[1] || (U[1] = (m) => k.value.takeawayCatalog = m),
            items: e.value,
            class: "mb-24",
            label: p(b)("menu.publish.update_catalog_dialog.sections.pos_takeaway.label")
          }, null, 8, ["modelValue", "items", "label"]),
          h(B, {
            modelValue: k.value.pickupCatalog,
            "onUpdate:modelValue": U[2] || (U[2] = (m) => k.value.pickupCatalog = m),
            items: e.value,
            label: p(b)("menu.publish.update_catalog_dialog.sections.pickup.label")
          }, null, 8, ["modelValue", "items", "label"]),
          f("div", $t, [
            f("div", At, L(p(b)("menu.publish.update_catalog_dialog.sections.additional.title")), 1),
            f("div", Ut, L(p(b)("menu.publish.update_catalog_dialog.sections.additional.subtitle")), 1),
            (y(!0), V(j, null, Q(O.catalogs, (m) => (y(), V("div", {
              key: m._id
            }, [
              h(J, {
                modelValue: k.value.additionalCatalogs,
                "onUpdate:modelValue": U[3] || (U[3] = (g) => k.value.additionalCatalogs = g),
                label: m.name,
                value: m._id
              }, null, 8, ["modelValue", "label", "value"])
            ]))), 128))
          ])
        ]),
        _: 1
      }, 8, ["modelValue", "onOn:clickedAway"]);
    };
  }
}), Ot = {
  class: "flex flex-col p-24 bg-fm-color-neutral-white min-h-[calc(100dvh-56px)] xs:max-h-[calc(100dvh-56px)]"
}, Tt = {
  class: "flex items-center xs:mb-8 mb-24"
}, Nt = {
  class: "mr-8"
}, Rt = {
  class: "fm-typo-en-title-md-600"
}, Et = {
  class: "xs:hidden mr-16"
}, Lt = {
  class: "xs:hidden mr-16"
}, zt = {
  class: "xs:hidden"
}, jt = {
  class: "pb-8 flex justify-between items-start xs:flex-col xs:items-stretch gap-8"
}, Ht = {
  class: "grow flex flex-col gap-4"
}, Yt = {
  class: "flex gap-8 items-center"
}, Jt = {
  class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary"
}, Kt = {
  class: "space-y-4"
}, qt = {
  class: "fm-typo-en-body-lg-600"
}, Gt = {
  class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
}, Wt = {
  class: "flex gap-8"
}, Qt = {
  class: "xs:block hidden fixed bottom-72 right-16"
}, da = /* @__PURE__ */ G({
  __name: "Publish",
  setup(O) {
    const S = De(), {
      t: s
    } = Z(), b = ({
      row: a
    }) => {
      const C = a.status === "latest";
      return h(He, {
        label: s(C ? "menu.publish.table.status.latest" : "menu.publish.table.status.outdated"),
        variant: C ? "success" : "warning"
      }, null);
    }, i = M({}), _ = [{
      accessorKey: "name",
      header: () => s("menu.publish.table.columns.restaurant"),
      cell: (a) => a.getValue(),
      enableSorting: !0
    }, {
      accessorKey: "catalog",
      header: () => s("menu.publish.table.columns.default"),
      enableSorting: !1,
      cell: (a) => a.getValue().default
    }, {
      accessorKey: "catalog",
      header: () => s("menu.publish.table.columns.pos_takeaway"),
      enableSorting: !1,
      cell: (a) => a.getValue().takeaway
    }, {
      accessorKey: "catalog",
      header: () => s("menu.publish.table.columns.pickup"),
      enableSorting: !1,
      cell: (a) => a.getValue().pickup
    }, {
      accessorKey: "updatedAt",
      header: () => s("menu.publish.table.columns.version"),
      enableSorting: !1,
      cell: (a) => {
        const C = a.getValue();
        return o(C);
      }
    }, {
      accessorKey: "status",
      header: () => s("menu.common.labels.status"),
      enableSorting: !1,
      cell: (a) => h(b, {
        row: a.row.original
      }, null)
    }, {
      accessorKey: "_id",
      header: "",
      size: 52,
      enableSorting: !1,
      cell: (a) => {
        const C = a.row.original;
        return T("div", {
          class: "flex justify-end gap-8"
        }, [t.value && C.revertConfig ? Je(T(W.FmButton, {
          prependIcon: "undo",
          variant: "secondary",
          onClick: te(async () => {
            await l(a.row.original);
          }, ["stop", "prevent"])
        }), s("menu.publish.actions.revert")) : null, T(W.FmButton, {
          label: s("menu.publish.actions.publish"),
          icon: "ios_share",
          variant: "secondary",
          onClick: te(async () => {
            const A = U(a.row.original);
            await x(A);
          }, ["stop", "prevent"])
        })]);
      },
      meta: {
        width: "150px"
      }
    }], d = M(""), v = M(), e = _e(), k = ke(), t = R(() => e.version !== q.F_MENU_VERSION.enum.v3);
    async function l(a) {
      a.revertConfig && k.open({
        title: "Revert menu",
        contentComponent: Xe,
        contentComponentProps: {
          restaurant: a
        },
        primaryActions: {
          text: "Revert",
          close: !0
        },
        secondaryActions: {
          text: "Cancel",
          close: !0
        }
      }).onPrimary(async () => {
        await w.minor(async () => {
          await e.revertRestaurantMenu(a._id);
        }, {
          customId: a._id,
          message: `Revert menu of ${a.name}`
        });
      });
    }
    const n = R(() => s("menu.publish.labels.main_version", {
      version: o(e.state.menu.updatedAt)
    }));
    function o(a) {
      return a ? z(a).format("DD/MM/YYYY hh:mmA") : "";
    }
    const r = R(() => e.state.menu.modules.catalog), u = R(() => w.queue.value.some((a) => a.id === e.state.menu._id));
    function c(a) {
      var C;
      return a ? ((C = r.value.find((A) => A._id === a)) == null ? void 0 : C.name) ?? s("menu.publish.labels.catalog.invalid") : s("menu.publish.labels.catalog.main");
    }
    function U(a) {
      return {
        restaurantId: a._id,
        catalogId: a.catalogId,
        takeawayCatalog: a.takeawayCatalog,
        pickupCatalog: a.pickupCatalog || null,
        additionalCatalogs: a.additionalCatalogs
      };
    }
    function B(a) {
      var A;
      const C = U(a);
      (A = v.value) == null || A.show(C);
    }
    const J = ce(), w = ve(J);
    async function x(a) {
      var A;
      const C = (A = g.value.find((K) => K._id === a.restaurantId)) == null ? void 0 : A.name;
      await w.minor(async () => await e.publishMenu(a), {
        customId: e.state.menu._id,
        message: `Publishing menu for ${C}`,
        successMessage: `Published to ${C}`
      });
    }
    const m = M(null), g = R(() => {
      const a = d.value.toLowerCase(), C = e.state.menu.updatedAt;
      return e.state.restaurants.filter((A) => {
        var K;
        return !m.value || ((K = m.value) == null ? void 0 : K.includes(A._id));
      }).map((A) => ({
        ...A,
        catalog: {
          default: c(A.catalogId),
          takeaway: c(A.takeawayCatalog),
          pickup: c(A.pickupCatalog)
        },
        status: C === A.updatedAt ? "latest" : "outdated"
      })).filter((A) => Oe(A, F.value)).filter(({
        name: A,
        catalog: K
      }) => a ? A.toLowerCase().includes(a) || K.default.toLowerCase().includes(a) || K.takeaway.toLowerCase().includes(a) || K.pickup.toLowerCase().includes(a) : !0);
    }), F = M({
      logic: "AND",
      rules: []
    }), D = [{
      type: "string",
      key: "status",
      entity: "menu",
      values: ["latest", "outdated"]
    }], I = M(0), N = M(null), ee = M(null), se = M(null);
    async function Fe() {
      await w.minor(async () => await e.readRestaurants(), {
        customId: e.state.menu._id
      }), await e.getNextSchedulerPublish(), e.runningPublishJob !== null ? N.value === null && (N.value = setInterval(async () => {
        await oe();
      }, 3e4)) : (se.value && (J.close(se.value), se.value = null), N.value !== null && (clearInterval(N.value), N.value = null), ee.value = null);
    }
    async function ne(a) {
      if (u.value) return;
      const C = Object.keys(i.value).filter((H) => i.value[H]), A = C.length === 0 || C.length === g.value.length ? g.value : g.value.filter((H) => C.includes(H._id));
      if (a ? a.restaurantIds.length === e.state.restaurants.length : g.value.length === e.state.restaurants.length && (C.length === 0 || C.length === g.value.length))
        await w.minor(async () => {
          await e.publishAllMenu(a == null ? void 0 : a.schedulerTime);
        }, {
          successMessage: "Menu publish registered for all restaurants."
        }), ee.value = !1;
      else {
        const H = (a == null ? void 0 : a.restaurantIds) || A.map((ue) => ue._id);
        await w.minor(async () => {
          await e.publishMultipleMenu(H, a == null ? void 0 : a.schedulerTime, !1);
        }, {
          successMessage: `Menu publish registered for ${a != null && a.restaurantIds ? a.restaurantIds.length : A.length} restaurant(s).`
        });
      }
      ee.value = !1, I.value = await e.getPublishRestaurantsProgress(), N.value !== null && (clearInterval(N.value), N.value = null), N.value = setInterval(async () => {
        await oe();
      }, 3e4);
    }
    async function oe() {
      await e.getNextSchedulerPublish(), e.runningPublishJob !== null ? (ee.value = !1, I.value = await e.getPublishRestaurantsProgress()) : (ee.value = !0, N.value !== null && (clearInterval(N.value), N.value = null));
    }
    return de(() => I.value, async (a) => {
      await e.readRestaurants();
    }), ie(async () => {
      await e.getNextSchedulerPublish(), N.value === null && (N.value = setInterval(async () => {
        await oe();
      }, 3e4));
    }), Be(() => {
      N.value != null && (clearInterval(N.value), N.value = null);
    }), (a, C) => {
      const A = $("FmChip"), K = $("FmSpacer"), H = $("FmButton"), ue = $("FmBadge"), Ve = $("FmSearch"), Ie = $("FmTable"), Pe = $("FmListItem"), Me = $("FmList");
      return y(), V(j, null, [f("div", Ot, [f("div", Tt, [f("div", Nt, [f("div", Rt, L(p(s)("menu.publish.title")), 1)]), h(A, {
        label: n.value,
        class: "xs:hidden text-fm-color-primary bg-fm-color-system-warning-100"
      }, null, 8, ["label"]), h(K), f("div", Et, [h(H, {
        disabled: u.value,
        label: p(s)("menu.publish.actions.refresh"),
        variant: "secondary",
        onClick: C[0] || (C[0] = () => Fe())
      }, null, 8, ["disabled", "label"])]), f("div", Lt, [h(Pt, {
        progress: I.value,
        restaurants: g.value,
        onPublishMenu: C[1] || (C[1] = (P) => ne(P))
      }, {
        default: E(({
          trigger: P
        }) => [p(e).runningPublishJob !== null ? (y(), Y(ue, {
          key: 0,
          variant: "critical",
          value: 1
        }, {
          default: E(() => [h(H, {
            variant: "secondary",
            disabled: u.value,
            label: p(s)("menu.publish.actions.publish_progress"),
            onClick: P
          }, null, 8, ["disabled", "label", "onClick"])]),
          _: 2
        }, 1024)) : (y(), Y(H, {
          key: 1,
          variant: "secondary",
          disabled: u.value,
          label: p(s)("menu.publish.actions.publish_progress"),
          onClick: P
        }, null, 8, ["disabled", "label", "onClick"]))]),
        _: 1
      }, 8, ["progress", "restaurants"])]), f("div", zt, [h(H, {
        disabled: u.value,
        icon: "ios_share",
        label: p(s)("menu.publish.actions.publish_all"),
        variant: "primary",
        onClick: C[2] || (C[2] = () => ne())
      }, null, 8, ["disabled", "label"])])]), f("div", jt, [h(p(ye), {
        multiple: "",
        modelValue: m.value,
        "onUpdate:modelValue": C[4] || (C[4] = (P) => m.value = P)
      }, {
        "append-right": E(() => [h(p(Te), {
          modelValue: F.value,
          "onUpdate:modelValue": C[3] || (C[3] = (P) => F.value = P),
          attributes: D
        }, null, 8, ["modelValue"])]),
        _: 1
      }, 8, ["modelValue"]), h(Ve, {
        modelValue: d.value,
        "onUpdate:modelValue": C[5] || (C[5] = (P) => d.value = P),
        autofocus: "",
        class: "w-[320px] xs:w-full",
        placeholder: p(s)("menu.publish.table.search.placeholder")
      }, null, 8, ["modelValue", "placeholder"])]), g.value.length > 0 ? (y(), V(j, {
        key: 0
      }, [h(Ce, {
        class: "xs:hidden block"
      }, {
        default: E(() => [h(Ie, {
          modelValue: i.value,
          "onUpdate:modelValue": C[6] || (C[6] = (P) => i.value = P),
          "get-row-id": (P) => P._id,
          "column-defs": _,
          loading: u.value,
          "page-size": g.value.length,
          "row-data": g.value,
          shrinkAt: !1,
          virtual: !0,
          selection: "multiple",
          "hide-footer": "",
          "pin-header-row": "",
          onRowClick: C[7] || (C[7] = (P) => B(P.original))
        }, null, 8, ["modelValue", "get-row-id", "loading", "page-size", "row-data"])]),
        _: 1
      }), h(Me, {
        class: "flex-col flex-1 min-h-0 overflow-auto xs:flex hidden w-full pb-64",
        separator: ""
      }, {
        default: E(() => [(y(!0), V(j, null, Q(g.value, (P) => (y(), Y(Pe, {
          key: P._id,
          label: P.name,
          style: {
            padding: "12px 0 !important"
          },
          onClick: () => B(P)
        }, {
          default: E(() => [f("div", Ht, [f("div", Yt, [f("div", Jt, L(o(P.updatedAt)), 1), h(b, {
            row: P
          }, null, 8, ["row"])]), f("div", Kt, [f("div", qt, L(P.name), 1), f("div", Gt, [f("div", null, "Default: " + L(P.catalog.default), 1), f("div", null, "POS takeaway: " + L(P.catalog.takeaway), 1), f("div", null, "Pickup: " + L(P.catalog.pickup), 1)])])]), f("div", Wt, [t.value && P.revertConfig ? (y(), Y(H, {
            key: 0,
            disabled: u.value,
            icon: "undo",
            variant: "tertiary",
            onClick: te(() => l(P), ["stop"])
          }, null, 8, ["disabled", "onClick"])) : X("", !0), h(H, {
            disabled: u.value,
            icon: "ios_share",
            variant: "tertiary",
            onClick: te(() => x(U(P)), ["stop"])
          }, null, 8, ["disabled", "onClick"])])]),
          _: 2
        }, 1032, ["label", "onClick"]))), 128))]),
        _: 1
      })], 64)) : (y(), Y(p(be), {
        key: 1,
        title: p(s)("menu.publish.empty.title"),
        subtitle: p(s)("menu.publish.empty.subtitle"),
        action: {
          text: p(s)("menu.publish.empty.action"),
          icon: "add",
          callback: () => {
            p(S).push({
              name: "$settings-my-business"
            });
          }
        }
      }, null, 8, ["title", "subtitle", "action"]))]), f("div", Qt, [h(H, {
        disabled: u.value,
        icon: "ios_share",
        label: p(s)("menu.publish.actions.publish_all"),
        variant: "fab",
        onClick: C[8] || (C[8] = () => ne())
      }, null, 8, ["disabled", "label"])]), h(Dt, {
        ref_key: "updateCatalogDialogRef",
        ref: v,
        catalogs: r.value,
        onOnComplete: x
      }, null, 8, ["catalogs"])], 64);
    };
  }
});
export {
  da as default
};
