import { m as F, u as f } from "./app-Bpb4394e.js";
import { useCoreStore as v } from "@feedmepos/mf-common";
import { ref as _, defineComponent as h, resolveComponent as l, openBlock as y, createElementBlock as g, renderSlot as k, createVNode as p, withCtx as S } from "vue";
const m = F((e, t) => {
  const r = f(), s = v();
  return {
    async getInventoryForecast() {
      var a;
      const n = ((a = s.currentBusiness.value) == null ? void 0 : a._id) ?? "", o = r.currentLocationId ?? "", i = `${e.dataBackendUrl}/${n}/${o}/inventory-forecast`;
      try {
        return await t.get(i);
      } catch {
        return { skus: [] };
      }
    },
    async getPurchaseOrderForecast(n, o) {
      var d;
      const i = ((d = s.currentBusiness.value) == null ? void 0 : d._id) ?? "", a = r.currentLocationId ?? "", u = `${e.dataBackendUrl}/${i}/${a}/purchase-order-forecast?days=${n}${o ? `&template_id=${o}` : ""}`;
      try {
        return await t.get(u);
      } catch {
        return { skus: [] };
      }
    }
  };
});
function O() {
  return {
    inventoryForecast: { skus: [] },
    purchaseOrderForecast: { skus: [] }
  };
}
const c = _(O());
function b() {
  return {
    // state
    get inventoryForecast() {
      return c.value.inventoryForecast;
    },
    set inventoryForecast(e) {
      c.value.inventoryForecast = e;
    },
    get purchaseOrderForecast() {
      return c.value.purchaseOrderForecast;
    },
    set purchaseOrderForecast(e) {
      c.value.purchaseOrderForecast = e;
    },
    // actions
    async readStockEstimateBalance() {
      const e = m();
      this.inventoryForecast = await e.getInventoryForecast();
    },
    async readPurchaseOrder(e, t) {
      const r = m();
      this.purchaseOrderForecast = await r.getPurchaseOrderForecast(e, t);
    }
  };
}
function E(e) {
  let t = e.substring(e.indexOf("_") + 1);
  return t.includes("_") && (t = t.substring(0, t.lastIndexOf("_"))), Number.isNaN(Date.parse(t)) ? null : new Date(t).toISOString();
}
const I = { class: "flex items-center gap-8" }, $ = "Experience enhanced inventory features with premium plan.", z = /* @__PURE__ */ h({
  __name: "PremiumBadge",
  props: {
    zIndex: {}
  },
  setup(e) {
    return (t, r) => {
      const s = l("FmPill"), n = l("FmTooltip");
      return y(), g("div", I, [
        k(t.$slots, "default"),
        p(n, {
          variant: "plain",
          placement: "top",
          content: $,
          "z-index": t.zIndex
        }, {
          default: S(() => [
            p(s, { variant: "premium" })
          ]),
          _: 1
        }, 8, ["z-index"])
      ]);
    };
  }
});
export {
  z as _,
  E as i,
  b as u
};
