import { u as useBagStore, s as sectionsData, _ as _sfc_main$3, a as _sfc_main$4, b as _sfc_main$5, c as _sfc_main$7, d as _sfc_main$8, e as _sfc_main$9, f as _sfc_main$a } from "./index.cf02a220.js";
import { _ as __unplugin_components_1 } from "./VControl.58ce19cc.js";
import { _ as _sfc_main$6 } from "./VField.b3125b15.js";
import { _ as _export_sfc, u as useUserSession } from "./index.591f3bfe.js";
import { o as openBlock, b as createElementBlock, m as createBaseVNode, d as defineComponent, r as ref, X as reactive, h as computed, s as createVNode, q as unref, y as withCtx, t as withDirectives, ah as vModelText, F as Fragment, Y as renderList, Z as createCommentVNode, D as useHead } from "./vendor.dd48a589.js";
import { u as useProductSession } from "./masterService.642860c6.js";
import { p as pageTitle } from "./sidebarLayoutState.bc85911b.js";
import "./VModal.2ef11452.js";
import "./VIconButton.a39b0b9b.js";
import "./VLoader.3dcc431b.js";
import "./mesaService.a6ec9502.js";
import "./VButtons.79021ab7.js";
const _sfc_main$2 = {};
const _hoisted_1$2 = /* @__PURE__ */ createBaseVNode("h5", null, null, -1);
const _hoisted_2$1 = [
  _hoisted_1$2
];
function _sfc_render(_ctx, _cache) {
  return openBlock(), createElementBlock("div", null, _hoisted_2$1);
}
var __unplugin_components_7 = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render]]);
var PosRestaurant_vue_vue_type_style_index_0_lang = "";
const _hoisted_1$1 = { class: "food-delivery-dashboard" };
const _hoisted_2 = { class: "left" };
const _hoisted_3 = { class: "left-body" };
const _hoisted_4 = { class: "restaurants" };
const _hoisted_5 = { class: "pt-3" };
const _hoisted_6 = { class: "restaurants-list" };
const _hoisted_7 = { class: "columns is-mobile is-multiline" };
const _hoisted_8 = /* @__PURE__ */ createBaseVNode("div", {
  class: "is-hidden-desktop",
  style: { "min-height": "150px" }
}, null, -1);
const _hoisted_9 = {
  key: 0,
  class: "is-hidden-desktop cart-bottom-fixed h-hidden-tablet-l"
};
const _hoisted_10 = { class: "columns is-mobile is-centered m-custom" };
const _hoisted_11 = { class: "column is-11" };
const _hoisted_12 = { class: "right fixed-parent is-hidden-mobile h-hidden-tablet-p only-pos" };
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
  setup(__props) {
    const textSearch = ref("");
    const userSession = useUserSession();
    const productSession = useProductSession();
    const bagStore = useBagStore();
    const posBag = reactive({
      products: [],
      total: 0,
      barman: userSession.name
    });
    const state = reactive({
      products: productSession.products,
      products_filter: productSession.products,
      openDialogDocument: false,
      loading: false,
      generatedDocument: false,
      sections: sectionsData,
      categories: productSession.categories
    });
    const clickAddProduct = (item) => {
      bagStore.addProduct(item);
    };
    const openDialogDocument = () => {
      if (bagStore.getProducts().length > 0) {
        posBag.products = bagStore.getProducts();
        posBag.total = bagStore.getTotal();
        state.openDialogDocument = true;
      }
    };
    const closeDialogDocument = () => {
      posBag.products = [];
      posBag.total = 0;
      posBag.enterAmount = 0;
      bagStore.reset();
      state.openDialogDocument = false;
    };
    const products_filter = computed(() => {
      if (textSearch.value.length > 0) {
        return state.products.filter((item) => item.name.toLowerCase().includes(textSearch.value.toLowerCase()));
      } else {
        return state.products;
      }
    });
    const back = () => {
      console.log("back");
      state.openDialogDocument = false;
    };
    const selectCategory = (id) => {
      if (id === 0) {
        state.products = state.products_filter;
      } else {
        state.products = state.products_filter.filter((x) => x.categoryId === id);
      }
    };
    return (_ctx, _cache) => {
      const _component_CashDialog = _sfc_main$3;
      const _component_DocumentDialog = _sfc_main$4;
      const _component_CategoriesNavBar = _sfc_main$5;
      const _component_VControl = __unplugin_components_1;
      const _component_VField = _sfc_main$6;
      const _component_ProductPos = _sfc_main$7;
      const _component_CartMobile = _sfc_main$8;
      const _component_Cart = __unplugin_components_7;
      const _component_Bag = _sfc_main$9;
      return openBlock(), createElementBlock(Fragment, null, [
        createVNode(_component_CashDialog),
        createVNode(_component_DocumentDialog, {
          "pos-bag": unref(posBag),
          open: unref(state).openDialogDocument,
          onClose: closeDialogDocument,
          onBack: back
        }, null, 8, ["pos-bag", "open"]),
        createBaseVNode("div", _hoisted_1$1, [
          createBaseVNode("div", _hoisted_2, [
            createBaseVNode("div", _hoisted_3, [
              createBaseVNode("div", _hoisted_4, [
                createVNode(_component_CategoriesNavBar, { onSelectcategory: selectCategory }),
                createBaseVNode("div", _hoisted_5, [
                  createVNode(_component_VField, null, {
                    default: withCtx(() => [
                      createVNode(_component_VControl, { icon: "feather:search" }, {
                        default: withCtx(() => [
                          withDirectives(createBaseVNode("input", {
                            "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => textSearch.value = $event),
                            type: "text",
                            class: "input is-rounded",
                            placeholder: "Busca un producto ..."
                          }, null, 512), [
                            [vModelText, textSearch.value]
                          ])
                        ]),
                        _: 1
                      })
                    ]),
                    _: 1
                  })
                ]),
                createBaseVNode("div", _hoisted_6, [
                  createBaseVNode("div", _hoisted_7, [
                    (openBlock(true), createElementBlock(Fragment, null, renderList(unref(products_filter), (product) => {
                      return openBlock(), createElementBlock("div", {
                        key: product.id,
                        class: "column is-6-mobile is-4-tablet is-3-desktop"
                      }, [
                        createVNode(_component_ProductPos, {
                          product,
                          onClickAddProduct: clickAddProduct
                        }, null, 8, ["product"])
                      ]);
                    }), 128))
                  ])
                ])
              ])
            ]),
            _hoisted_8
          ]),
          unref(bagStore).getProducts().length > 0 ? (openBlock(), createElementBlock("div", _hoisted_9, [
            createBaseVNode("div", _hoisted_10, [
              createBaseVNode("div", _hoisted_11, [
                createVNode(_component_CartMobile, { onFinalizeSale: openDialogDocument }),
                createVNode(_component_Cart)
              ])
            ])
          ])) : createCommentVNode("", true),
          createBaseVNode("div", _hoisted_12, [
            createVNode(_component_Bag, { onFinalizeSale: openDialogDocument })
          ])
        ])
      ], 64);
    };
  }
});
const _hoisted_1 = { class: "page-content-inner" };
const _sfc_main = /* @__PURE__ */ defineComponent({
  setup(__props) {
    pageTitle.value = "Mozo.pe";
    useHead({
      title: "Mozo.pe"
    });
    return (_ctx, _cache) => {
      const _component_LockedScreen = _sfc_main$a;
      const _component_PosRestaurant = _sfc_main$1;
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createVNode(_component_LockedScreen),
        createVNode(_component_PosRestaurant)
      ]);
    };
  }
});
export { _sfc_main as default };
