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$9, e as _sfc_main$a, f as _sfc_main$b } from "./index.34c37c3c.js";
import { _ as __unplugin_components_1 } from "./VControl.36f1f0b8.js";
import { _ as _sfc_main$6 } from "./VField.ae64c3d0.js";
import { _ as _sfc_main$8 } from "./VAvatar.864329ab.js";
import { _ as _export_sfc, u as useUserSession } from "./index.82e0aff8.js";
import { o as openBlock, b as createElementBlock, p as createBaseVNode, d as defineComponent, r as ref, Y as reactive, h as computed, G as onMounted, t as createVNode, s as unref, v as withCtx, x as withDirectives, ag as vModelText, y as vModelCheckbox, n as normalizeClass, B as toDisplayString, F as Fragment, Z as renderList, av as TransitionGroup, _ as createCommentVNode, E as useHead } from "./vendor.7db31232.js";
import { u as useProductSession } from "./masterService.cf65685b.js";
import { p as pageTitle } from "./sidebarLayoutState.c465df13.js";
import "./VModal.af15beb6.js";
import "./VLoader.08d53c1d.js";
import "./mesaService.6da053b4.js";
import "./VIconButton.4aa07a0a.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_8 = /* @__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: "columns is-multiline is-mobile" };
const _hoisted_6 = {
  class: "column is-10",
  style: { "padding-bottom": "0px" }
};
const _hoisted_7 = { class: "pt-3 searchCategory-content" };
const _hoisted_8 = {
  xmlns: "http://www.w3.org/2000/svg",
  width: "21",
  height: "21",
  viewBox: "0 0 14 14"
};
const _hoisted_9 = ["stroke"];
const _hoisted_10 = { class: "tooltip-text" };
const _hoisted_11 = {
  class: "column is-2",
  style: { "padding-bottom": "0px", "width": "12%" }
};
const _hoisted_12 = { class: "tabs-wrapper" };
const _hoisted_13 = { class: "tabs-inner" };
const _hoisted_14 = { class: "tabs is-centered mb-1" };
const _hoisted_15 = {
  style: { "border": "none" },
  class: ""
};
const _hoisted_16 = /* @__PURE__ */ createBaseVNode("span", null, [
  /* @__PURE__ */ createBaseVNode("i", {
    "aria-hidden": "true",
    class: "iconify",
    "data-icon": "feather:grid"
  })
], -1);
const _hoisted_17 = [
  _hoisted_16
];
const _hoisted_18 = /* @__PURE__ */ createBaseVNode("span", null, [
  /* @__PURE__ */ createBaseVNode("i", {
    "aria-hidden": "true",
    class: "iconify",
    "data-icon": "feather:list"
  })
], -1);
const _hoisted_19 = [
  _hoisted_18
];
const _hoisted_20 = /* @__PURE__ */ createBaseVNode("li", { class: "tab-naver" }, null, -1);
const _hoisted_21 = {
  key: 0,
  class: "restaurants-list"
};
const _hoisted_22 = { class: "columns is-mobile is-multiline" };
const _hoisted_23 = {
  key: 1,
  style: { "padding-top": "1%" },
  class: "flex-table"
};
const _hoisted_24 = /* @__PURE__ */ createBaseVNode("div", { class: "flex-table-header" }, [
  /* @__PURE__ */ createBaseVNode("span", { class: "is-grow" }, "Producto"),
  /* @__PURE__ */ createBaseVNode("span", null, "Codigo"),
  /* @__PURE__ */ createBaseVNode("span", { class: "cell-end" }, "Precio")
], -1);
const _hoisted_25 = { class: "flex-list-inner" };
const _hoisted_26 = ["onClick"];
const _hoisted_27 = { class: "flex-table-cell is-media is-grow" };
const _hoisted_28 = { class: "item-name dark-inverted" };
const _hoisted_29 = {
  class: "flex-table-cell",
  "data-th": "C\xF3digo"
};
const _hoisted_30 = { class: "light-text" };
const _hoisted_31 = {
  class: "flex-table-cell cell-end",
  "data-th": "Precio"
};
const _hoisted_32 = { class: "is-primary" };
const _hoisted_33 = /* @__PURE__ */ createBaseVNode("div", {
  class: "is-hidden-desktop",
  style: { "min-height": "150px" }
}, null, -1);
const _hoisted_34 = {
  key: 0,
  class: "is-hidden-desktop cart-bottom-fixed h-hidden-tablet-l"
};
const _hoisted_35 = { class: "columns is-mobile is-centered m-custom" };
const _hoisted_36 = { class: "column is-11" };
const _hoisted_37 = { class: "right fixed-parent is-hidden-mobile h-hidden-tablet-p only-pos" };
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
  setup(__props) {
    const userSession = useUserSession();
    const productSession = useProductSession();
    const textSearch = ref("");
    const searchByBarcode = ref(false);
    const bagStore = useBagStore();
    const isListItems = ref(false);
    const isBarcodeActive = ref(false);
    const tooltipMessage = ref("Activar b\xFAsqueda por c\xF3digo de barras");
    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) {
        if (searchByBarcode.value) {
          let itemFound = state.products.find((item) => item.barcode == textSearch.value);
          if (itemFound) {
            bagStore.addProduct(itemFound);
          }
          textSearch.value = "";
          return itemFound ? [itemFound] : [];
        } else {
          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);
      }
    };
    const changeSearchByBarcode = () => {
      isBarcodeActive.value = !isBarcodeActive.value;
      tooltipMessage.value = isBarcodeActive.value ? "Desactivar b\xFAsqueda por c\xF3digo de barras" : "Activar b\xFAsqueda por c\xF3digo de barras";
      let byBarcode = searchByBarcode.value ? 1 : 0;
      userSession.setSearchByBarcode(byBarcode);
    };
    onMounted(() => {
      searchByBarcode.value = userSession.searchByBarcode ? true : false;
    });
    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_VAvatar = _sfc_main$8;
      const _component_CartMobile = _sfc_main$9;
      const _component_Cart = __unplugin_components_8;
      const _component_Bag = _sfc_main$a;
      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, [
                createBaseVNode("div", _hoisted_5, [
                  createBaseVNode("div", _hoisted_6, [
                    createVNode(_component_CategoriesNavBar, { onSelectcategory: selectCategory })
                  ]),
                  createBaseVNode("div", _hoisted_7, [
                    createVNode(_component_VField, { class: "search-conteiner" }, {
                      default: withCtx(() => [
                        createVNode(_component_VControl, {
                          class: "input-container",
                          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]
                            ]),
                            createBaseVNode("label", null, [
                              withDirectives(createBaseVNode("input", {
                                "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => searchByBarcode.value = $event),
                                class: "barcode-toggle",
                                type: "checkbox",
                                onChange: changeSearchByBarcode
                              }, null, 544), [
                                [vModelCheckbox, searchByBarcode.value]
                              ]),
                              createBaseVNode("span", {
                                class: normalizeClass(["barcode-icon", { active: isBarcodeActive.value }])
                              }, [
                                (openBlock(), createElementBlock("svg", _hoisted_8, [
                                  createBaseVNode("path", {
                                    fill: "none",
                                    stroke: isBarcodeActive.value ? "#4caf50" : "#cfcfcf",
                                    "stroke-linecap": "round",
                                    "stroke-linejoin": "round",
                                    d: "M5.11.656H1.208a.49.49 0 0 0-.488.488v3.904m12.686 0V1.144a.49.49 0 0 0-.488-.488H9.014m0 12.688h3.904a.49.49 0 0 0 .488-.488V8.952m-12.687 0v3.904a.49.49 0 0 0 .488.488H5.11m5.696-9.552v6.416M3.194 3.792v6.416m5.709-6.416v4.666m0 1.75v-.291M7 3.792v4.666m0 1.75v-.291M5.097 3.792v4.666m0 1.75v-.291"
                                  }, null, 8, _hoisted_9)
                                ]))
                              ], 2),
                              createBaseVNode("span", _hoisted_10, toDisplayString(tooltipMessage.value), 1)
                            ])
                          ]),
                          _: 1
                        })
                      ]),
                      _: 1
                    }),
                    createBaseVNode("div", _hoisted_11, [
                      createBaseVNode("div", _hoisted_12, [
                        createBaseVNode("div", _hoisted_13, [
                          createBaseVNode("div", _hoisted_14, [
                            createBaseVNode("ul", _hoisted_15, [
                              createBaseVNode("li", {
                                class: normalizeClass([isListItems.value == false && "is-active"]),
                                style: { "border-bottom": "1px solid #e0e0e0" }
                              }, [
                                createBaseVNode("a", {
                                  onClick: _cache[2] || (_cache[2] = ($event) => isListItems.value = false)
                                }, _hoisted_17)
                              ], 2),
                              createBaseVNode("li", {
                                class: normalizeClass([isListItems.value == true && "is-active"]),
                                style: { "border-bottom": "1px solid #e0e0e0" }
                              }, [
                                createBaseVNode("a", {
                                  onClick: _cache[3] || (_cache[3] = ($event) => isListItems.value = true)
                                }, _hoisted_19)
                              ], 2),
                              _hoisted_20
                            ])
                          ])
                        ])
                      ])
                    ])
                  ])
                ]),
                !isListItems.value ? (openBlock(), createElementBlock("div", _hoisted_21, [
                  createBaseVNode("div", _hoisted_22, [
                    (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))
                  ])
                ])) : (openBlock(), createElementBlock("div", _hoisted_23, [
                  _hoisted_24,
                  createBaseVNode("div", _hoisted_25, [
                    createVNode(TransitionGroup, {
                      name: "list",
                      tag: "div"
                    }, {
                      default: withCtx(() => [
                        (openBlock(true), createElementBlock(Fragment, null, renderList(unref(products_filter), (item) => {
                          return openBlock(), createElementBlock("div", {
                            key: item.id,
                            class: "flex-table-item",
                            style: { "cursor": "pointer" },
                            onClick: ($event) => clickAddProduct(item)
                          }, [
                            createBaseVNode("div", _hoisted_27, [
                              createVNode(_component_VAvatar, {
                                picture: item.imageUrl,
                                size: "medium"
                              }, null, 8, ["picture"]),
                              createBaseVNode("div", null, [
                                createBaseVNode("span", _hoisted_28, toDisplayString(item.name), 1)
                              ])
                            ]),
                            createBaseVNode("div", _hoisted_29, [
                              createBaseVNode("span", _hoisted_30, toDisplayString(item.internalId), 1)
                            ]),
                            createBaseVNode("div", _hoisted_31, [
                              createBaseVNode("span", _hoisted_32, toDisplayString(item.currencyTypeSymbol) + " " + toDisplayString(item.price.toFixed(2)), 1)
                            ])
                          ], 8, _hoisted_26);
                        }), 128))
                      ]),
                      _: 1
                    })
                  ])
                ]))
              ])
            ]),
            _hoisted_33
          ]),
          unref(bagStore).getProducts().length > 0 ? (openBlock(), createElementBlock("div", _hoisted_34, [
            createBaseVNode("div", _hoisted_35, [
              createBaseVNode("div", _hoisted_36, [
                createVNode(_component_CartMobile, { onFinalizeSale: openDialogDocument }),
                createVNode(_component_Cart)
              ])
            ])
          ])) : createCommentVNode("", true),
          createBaseVNode("div", _hoisted_37, [
            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$b;
      const _component_PosRestaurant = _sfc_main$1;
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createVNode(_component_LockedScreen),
        createVNode(_component_PosRestaurant)
      ]);
    };
  }
});
export { _sfc_main as default };
