import { defineComponent as Y, ref as b, computed as K, watch as M, resolveComponent as V, openBlock as s, createElementBlock as r, createElementVNode as t, toDisplayString as F, Fragment as U, renderList as G, createVNode as p, createBlock as P, createCommentVNode as q, nextTick as fe, createSlots as ye, withCtx as T, normalizeClass as ee, unref as O, withModifiers as be, Teleport as xe } from "vue";
import { _ as _e } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-sUxHOj47.js";
import { B as A, g as he, r as ke, s as we, u as Te, a as R, b as Fe, c as De, d as te, e as Ce, f as Se } from "./predefined-templates-BAEoCP7i.js";
import { useSnackbar as Be } from "@feedmepos/ui-library";
import { _ as Ve } from "./_plugin-vue_export-helper-CHgC5LLL.js";
import { G as j, H as $e } from "./app-Bpb4394e.js";
import { useCoreStore as ze, useI18n as Ie } from "@feedmepos/mf-common";
import "./dayjs.min-D5mIeZ1x.js";
import "./inventory-core-dart.default-DanfWZQm.js";
import { F as Oe } from "./FmAdminBadge-DjnBAgyv.js";
const Pe = { class: "p-3" }, Ee = { class: "text-sm font-semibold text-gray-700 mb-4 pb-2 border-b border-gray-200" }, Ne = { class: "flex flex-col gap-3" }, Ue = {
  key: 0,
  class: "flex items-center justify-between py-1"
}, Ae = { class: "text-[13px] text-gray-600" }, He = { class: "text-[13px] text-gray-600" }, Le = ["value", "rows", "placeholder", "onInput"], Re = {
  key: 5,
  class: "flex items-center justify-between py-1"
}, je = { class: "text-[13px] text-gray-600" }, Me = ["value", "onInput"], Ge = /* @__PURE__ */ Y({
  __name: "BlockConfigPanel",
  props: {
    block: {}
  },
  emits: ["update"],
  setup(E, { emit: x }) {
    const g = E, f = x;
    function h(n) {
      var v;
      if ((v = n.config) != null && v.configFields && Array.isArray(n.config.configFields))
        return n.config.configFields.map((_) => ({ ..._ }));
      const c = A[n.tag];
      return c ? c.initialConfigFields() : [];
    }
    const d = b(h(g.block)), $ = K(() => {
      const n = A[g.block.tag];
      return (n == null ? void 0 : n.label) ?? g.block.tag;
    });
    M(
      () => g.block,
      (n) => {
        d.value = h(n);
      },
      { deep: !0 }
    );
    function i(n, c) {
      const v = d.value[n];
      v && (v.value = c, m());
    }
    function m() {
      f("update", {
        ...g.block.config || {},
        configFields: d.value.map((n) => ({ ...n }))
      });
    }
    return (n, c) => {
      const v = V("FmSwitch"), _ = V("FmTextField"), D = V("FmSelect");
      return s(), r("div", Pe, [
        t("div", Ee, F($.value) + " Settings ", 1),
        t("div", Ne, [
          (s(!0), r(U, null, G(d.value, (a, w) => (s(), r("div", {
            key: a.key
          }, [
            a.type === "toggle" ? (s(), r("div", Ue, [
              t("label", Ae, F(a.label), 1),
              p(v, {
                "model-value": a.value,
                "onUpdate:modelValue": (y) => i(w, y)
              }, null, 8, ["model-value", "onUpdate:modelValue"])
            ])) : a.type === "text" ? (s(), P(_, {
              key: 1,
              label: a.label,
              "model-value": a.value,
              placeholder: a.placeholder,
              "onUpdate:modelValue": (y) => i(w, y)
            }, null, 8, ["label", "model-value", "placeholder", "onUpdate:modelValue"])) : a.type === "textarea" ? (s(), r(U, { key: 2 }, [
              t("div", He, F(a.label), 1),
              t("textarea", {
                class: "w-full font-mono text-[13px] p-2 border border-gray-300 rounded resize-y box-border focus:outline-none focus:border-blue-600",
                value: a.value,
                rows: a.rows ?? 8,
                placeholder: a.placeholder,
                onInput: (y) => i(w, y.target.value)
              }, null, 40, Le)
            ], 64)) : a.type === "select" ? (s(), P(D, {
              key: 3,
              label: a.label,
              "model-value": a.value,
              items: a.options || [],
              "item-label": "label",
              "item-value": "value",
              "onUpdate:modelValue": (y) => i(w, y)
            }, null, 8, ["label", "model-value", "items", "onUpdate:modelValue"])) : a.type === "number" ? (s(), P(_, {
              key: 4,
              label: a.label,
              type: "number",
              "model-value": String(a.value),
              "onUpdate:modelValue": (y) => i(w, Number(y))
            }, null, 8, ["label", "model-value", "onUpdate:modelValue"])) : a.type === "color" ? (s(), r("div", Re, [
              t("label", je, F(a.label), 1),
              t("input", {
                type: "color",
                value: a.value,
                class: "color-input w-9 h-7 p-0 border border-gray-300 rounded cursor-pointer bg-transparent",
                onInput: (y) => i(w, y.target.value)
              }, null, 40, Me)
            ])) : q("", !0)
          ]))), 128))
        ])
      ]);
    };
  }
}), qe = /* @__PURE__ */ Ve(Ge, [["__scopeId", "data-v-1f00cb56"]]), Ke = { class: "h-full flex flex-col" }, Ye = { class: "flex-1 overflow-auto p-4 bg-gray-100" }, Je = /* @__PURE__ */ Y({
  __name: "TemplatePreview",
  props: {
    blocks: {},
    previewData: {},
    selectedBlockId: {},
    templateType: {}
  },
  setup(E) {
    const x = E, g = b(null);
    let f = null;
    function h() {
      return !f && g.value && (f = g.value.attachShadow({ mode: "open" })), f;
    }
    const d = K(() => x.previewData ?? he(x.templateType));
    M(
      () => [x.blocks, d.value, g.value],
      () => {
        const i = h();
        if (i) {
          try {
            const m = ke(x.blocks, d.value), n = we(m);
            i.innerHTML = `
        <style>
          :host { display: block; }
          .preview-scale-wrapper {
            transform-origin: top left;
            transform: scale(0.75);
            width: 133.33%;
          }
          .preview-content {
            max-width: 800px;
            margin: auto;
            padding: 30px;
            border: 1px solid #eee;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
            background: white;
            font-size: 16px;
            line-height: 1.5;
            font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif;
            color: #555;
          }
        </style>
        <div class="preview-scale-wrapper">
          <div class="preview-content">${n}</div>
        </div>
      `;
          } catch (m) {
            i.innerHTML = `<div style="color:red;padding:20px;">Error rendering template: ${m}</div>`;
          }
          fe(() => $(x.selectedBlockId));
        }
      },
      { deep: !0, immediate: !0 }
    ), M(
      () => x.selectedBlockId,
      (i) => $(i)
    );
    function $(i) {
      if (!f || (f.querySelectorAll("[data-block-id].highlight").forEach((n) => {
        n.classList.remove("highlight");
      }), !i)) return;
      const m = f.querySelector(`[data-block-id="${i}"]`);
      m && (m.classList.add("highlight"), m.scrollIntoView({ behavior: "smooth", block: "nearest" }));
    }
    return (i, m) => (s(), r("div", Ke, [
      m[0] || (m[0] = t("div", { class: "text-xs font-semibold text-gray-400 uppercase tracking-wider px-3 py-2 border-b border-gray-200" }, " Live Preview ", -1)),
      t("div", Ye, [
        t("div", {
          ref_key: "shadowHost",
          ref: g
        }, null, 512)
      ])
    ]));
  }
}), Qe = { class: "flex items-center gap-2 text-base font-semibold" }, We = { key: 1 }, Xe = { key: 2 }, Ze = {
  key: 0,
  class: "p-6"
}, et = {
  key: 0,
  class: "flex justify-center items-center h-40 text-gray-400"
}, tt = {
  key: 1,
  class: "grid grid-cols-2 gap-8"
}, lt = ["onClick"], ot = { class: "flex items-center justify-center w-12 h-12 rounded-xl bg-gray-100 text-gray-500 group-hover:bg-blue-100 group-hover:text-blue-600 transition-colors" }, at = { class: "text-center" }, st = { class: "text-sm font-semibold text-gray-700 group-hover:text-blue-700" }, nt = { class: "text-xs text-gray-400 mt-1" }, rt = {
  key: 0,
  class: "absolute top-2.5 right-2.5 text-[10px] font-medium text-green-600 bg-green-50 border border-green-200 px-2 py-0.5 rounded-full"
}, it = {
  key: 1,
  class: "absolute top-2.5 right-2.5 text-[10px] font-medium text-gray-400 bg-gray-100 px-2 py-0.5 rounded-full"
}, ut = {
  key: 1,
  class: "flex justify-center items-center h-[400px] text-gray-400"
}, dt = {
  key: 2,
  class: "flex h-[calc(100vh-120px)] border-t border-gray-200"
}, ct = { class: "w-[280px] border-r border-gray-200 overflow-y-auto shrink-0" }, pt = { class: "px-3 pt-3 pb-2" }, mt = { class: "flex flex-col" }, vt = ["onClick"], gt = { class: "border-y border-gray-100" }, ft = ["onDragstart", "onDragover", "onDrop", "onClick"], yt = { class: "flex-1" }, bt = { class: "flex gap-1 opacity-50 hover:opacity-100" }, xt = {
  key: 0,
  class: "py-6 px-4 text-center text-gray-400 text-[13px]"
}, _t = {
  key: 0,
  class: "border-t border-gray-200"
}, ht = {
  key: 1,
  class: "flex items-center justify-center text-gray-400 text-[13px] py-8"
}, kt = { class: "p-3 border-t border-gray-200" }, wt = { class: "flex-1 overflow-hidden" }, Tt = { class: "ml-auto flex gap-2" }, Ft = { class: "p-4" }, Dt = { class: "flex items-center gap-1.5 mt-3 text-xs text-amber-600 bg-amber-50 border border-amber-200 rounded px-3 py-2" }, Ct = { class: "p-4" }, St = { class: "flex items-center gap-1.5 mt-3 text-xs text-amber-600 bg-amber-50 border border-amber-200 rounded px-3 py-2" }, Bt = /* @__PURE__ */ Y({
  __name: "PrintTemplateEditorDialog",
  props: {
    modelValue: { type: Boolean }
  },
  emits: ["update:modelValue", "saved"],
  setup(E, { emit: x }) {
    const g = E, f = x, h = Te(), d = Be(), $ = ze(), i = K({
      get: () => g.modelValue,
      set: (l) => f("update:modelValue", l)
    }), m = b(!1), n = b(!1), c = b(R()), v = b(null), _ = b(j.Enum.purchaseOrder), D = b("Purchase Order Template"), a = b(null), w = b(!1), y = b(!1), C = b("select-type"), W = [
      {
        label: "Purchase Order",
        value: j.Enum.purchaseOrder,
        icon: "receipt_long",
        description: "Customize the layout for purchase order printouts"
      },
      {
        label: "Transfer Order",
        value: j.Enum.transferOrder,
        icon: "swap_horiz",
        description: "Customize the layout for transfer order printouts"
      },
      {
        label: "Goods Received Note",
        value: j.Enum.goodsReceivedNote,
        icon: "fact_check",
        description: "Customize the layout for GRN printouts"
      },
      {
        label: "Delivery Order",
        value: j.Enum.deliveryOrder,
        icon: "local_shipping",
        description: "Customize the layout for delivery order printouts"
      }
    ], H = b(/* @__PURE__ */ new Set()), J = K(
      () => c.value.find((l) => l.id === v.value) ?? null
    ), z = b(null), N = b(null);
    M(i, async (l) => {
      if (l) {
        C.value = "select-type", m.value = !0;
        try {
          const e = await h.browse();
          H.value = new Set(e.map((u) => u.type));
        } catch {
        } finally {
          m.value = !1;
        }
      }
    }), M(_, async () => {
      v.value = null, await X();
    });
    async function le(l) {
      _.value = l, await X(), C.value = "editor";
    }
    function Q() {
      return {
        purchaseOrder: "Purchase Order Template",
        transferOrder: "Transfer Order Template",
        goodsReceivedNote: "Goods Received Note Template",
        deliveryOrder: "Delivery Order Template"
      }[_.value] ?? "Purchase Order Template";
    }
    async function X() {
      m.value = !0;
      try {
        const l = await h.browse();
        H.value = new Set(l.map((u) => u.type));
        const e = l.find((u) => u.type === _.value);
        e ? (a.value = e._id, D.value = e.name, c.value = e.blocks.map((u) => ({ ...u }))) : (a.value = null, c.value = R(), D.value = Q());
      } catch {
        c.value = R(), D.value = Q();
      } finally {
        m.value = !1;
      }
    }
    function oe(l) {
      const e = {
        id: Fe(),
        tag: l,
        config: De(l)
      };
      c.value.push(e), v.value = e.id;
    }
    function ae(l) {
      const e = c.value.findIndex((u) => u.id === l);
      e >= 0 && (c.value.splice(e, 1), v.value === l && (v.value = null));
    }
    function se(l) {
      const e = c.value.find((u) => u.id === v.value);
      if (e) {
        const u = l.configFields || [], L = te(e.tag);
        e.config = { configFields: u, templateHtml: L };
      }
    }
    function ne(l) {
      z.value = l;
    }
    function re(l, e) {
      l.preventDefault(), N.value = e;
    }
    function ie() {
      N.value = null;
    }
    function ue(l) {
      if (z.value === null || z.value === l) {
        z.value = null, N.value = null;
        return;
      }
      const e = c.value.splice(z.value, 1)[0];
      c.value.splice(l, 0, e), z.value = null, N.value = null;
    }
    function de() {
      z.value = null, N.value = null;
    }
    async function ce() {
      var l;
      n.value = !0;
      try {
        const e = (l = $.currentBusiness.value) == null ? void 0 : l._id;
        if (!e)
          throw new Error("Business ID is missing. Please select a business first.");
        const u = c.value.map((o) => {
          var Z;
          const k = ((Z = o.config) == null ? void 0 : Z.configFields) || [], I = te(o.tag, k);
          return {
            ...o,
            config: { configFields: k, templateHtml: I }
          };
        }), L = Ce(u), S = {
          name: D.value,
          type: _.value,
          blocks: L,
          businessId: e,
          createdAt: (/* @__PURE__ */ new Date()).toISOString(),
          updatedAt: (/* @__PURE__ */ new Date()).toISOString()
        };
        let B;
        a.value ? B = await h.update(a.value, {
          _id: a.value,
          ...S
        }) : (B = await h.create(S), a.value = B._id), H.value.add(_.value), y.value = !1, d == null || d.open({
          title: "Success",
          message: "Print template saved",
          type: "success"
        }), f("saved", B), i.value = !1;
      } catch (e) {
        d == null || d.open({
          title: "Error",
          message: (e == null ? void 0 : e.message) || "Failed to save template",
          type: "error"
        });
      } finally {
        n.value = !1;
      }
    }
    async function pe() {
      if (a.value) {
        n.value = !0;
        try {
          await h.delete(a.value), a.value = null, c.value = R(), D.value = Q(), H.value.delete(_.value), w.value = !1, d == null || d.open({
            title: "Deleted",
            message: "Print template deleted. Default layout will be used.",
            type: "success"
          }), f("saved", null), i.value = !1;
        } catch (l) {
          d == null || d.open({
            title: "Error",
            message: (l == null ? void 0 : l.message) || "Failed to delete template",
            type: "error"
          });
        } finally {
          n.value = !1;
        }
      }
    }
    function me() {
      c.value = R(), v.value = null;
    }
    function ve(l) {
      var e;
      return ((e = A[l]) == null ? void 0 : e.label) ?? l;
    }
    function ge(l) {
      var e;
      return ((e = A[l]) == null ? void 0 : e.icon) ?? "widgets";
    }
    return (l, e) => {
      const u = V("FmIcon"), L = V("FmTextField"), S = V("FmButton"), B = V("FmDialog");
      return s(), r(U, null, [
        p(B, {
          modelValue: i.value,
          "onUpdate:modelValue": e[4] || (e[4] = (o) => i.value = o),
          overlay: !0,
          "close-button": "",
          "max-width": "98vw",
          "max-height": "98vh"
        }, ye({
          "dialog-header": T(() => {
            var o;
            return [
              t("div", Qe, [
                C.value === "editor" ? (s(), r("button", {
                  key: 0,
                  class: "flex items-center justify-center w-7 h-7 rounded hover:bg-gray-100 transition-colors text-gray-500",
                  onClick: e[0] || (e[0] = (k) => C.value = "select-type")
                }, [
                  p(u, {
                    name: "arrow_back",
                    size: "sm"
                  })
                ])) : q("", !0),
                C.value === "select-type" ? (s(), r("span", We, "Print Template Editor")) : (s(), r("span", Xe, F((o = W.find((k) => k.value === _.value)) == null ? void 0 : o.label) + " Template", 1))
              ])
            ];
          }),
          default: T(() => [
            C.value === "select-type" ? (s(), r("div", Ze, [
              e[7] || (e[7] = t("p", { class: "text-sm text-gray-500 mb-5" }, " Select a template type to customize its print layout. ", -1)),
              m.value ? (s(), r("div", et, " Loading... ")) : (s(), r("div", tt, [
                (s(), r(U, null, G(W, (o) => t("div", {
                  key: o.value,
                  class: ee(["group relative flex flex-col items-center gap-3 p-6 rounded-xl border-2 border-gray-200 cursor-pointer transition-all hover:border-blue-400 hover:shadow-md", {
                    "border-blue-500 bg-blue-50/50 shadow-md": _.value === o.value && C.value === "select-type"
                  }]),
                  onClick: (k) => le(o.value)
                }, [
                  t("div", ot, [
                    p(u, {
                      name: o.icon,
                      size: "sm"
                    }, null, 8, ["name"])
                  ]),
                  t("div", at, [
                    t("div", st, F(o.label), 1),
                    t("div", nt, F(o.description), 1)
                  ]),
                  H.value.has(o.value) ? (s(), r("span", rt, "Customized")) : (s(), r("span", it, "Default"))
                ], 10, lt)), 64))
              ]))
            ])) : m.value ? (s(), r("div", ut, e[8] || (e[8] = [
              t("div", null, "Loading template...", -1)
            ]))) : (s(), r("div", dt, [
              t("div", ct, [
                t("div", pt, [
                  p(L, {
                    modelValue: D.value,
                    "onUpdate:modelValue": e[1] || (e[1] = (o) => D.value = o),
                    placeholder: "Template name",
                    label: "Template Name"
                  }, null, 8, ["modelValue"])
                ]),
                e[9] || (e[9] = t("div", { class: "text-xs font-semibold text-gray-400 uppercase tracking-wider px-3 py-2" }, " Add Blocks ", -1)),
                t("div", mt, [
                  (s(!0), r(U, null, G(O($e).Values, (o) => (s(), r("div", {
                    key: o,
                    class: "group flex items-center gap-2 px-3 py-2 cursor-pointer text-[13px] text-gray-600 transition-colors hover:bg-gray-100",
                    onClick: (k) => oe(o)
                  }, [
                    p(u, {
                      name: O(A)[o].icon,
                      size: "sm"
                    }, null, 8, ["name"]),
                    t("span", null, F(O(A)[o].label), 1),
                    p(u, {
                      name: "add",
                      size: "sm",
                      class: "ml-auto opacity-0 text-blue-600 group-hover:opacity-100"
                    })
                  ], 8, vt))), 128))
                ]),
                e[10] || (e[10] = t("div", { class: "text-xs font-semibold text-gray-400 uppercase tracking-wider px-3 py-2 mt-2" }, " Block Order ", -1)),
                t("div", gt, [
                  (s(!0), r(U, null, G(c.value, (o, k) => (s(), r("div", {
                    key: o.id,
                    class: ee(["flex items-center gap-2 px-3 py-2 cursor-pointer text-[13px] text-gray-600 border-b border-gray-100 transition-colors hover:bg-gray-100", {
                      "bg-blue-50 border-l-[3px] border-l-blue-600": o.id === v.value,
                      "border-t-2 border-t-blue-600": N.value === k
                    }]),
                    draggable: "true",
                    onDragstart: (I) => ne(k),
                    onDragover: (I) => re(I, k),
                    onDragleave: ie,
                    onDrop: (I) => ue(k),
                    onDragend: de,
                    onClick: (I) => v.value = o.id
                  }, [
                    p(u, {
                      name: "drag_indicator",
                      size: "sm",
                      class: "cursor-grab text-gray-300"
                    }),
                    p(u, {
                      name: ge(o.tag),
                      size: "sm"
                    }, null, 8, ["name"]),
                    t("span", yt, F(ve(o.tag)), 1),
                    t("div", bt, [
                      p(u, {
                        name: "delete",
                        size: "sm",
                        class: "cursor-pointer text-gray-400 hover:text-red-500",
                        onClick: be((I) => ae(o.id), ["stop"])
                      }, null, 8, ["onClick"])
                    ])
                  ], 42, ft))), 128)),
                  c.value.length === 0 ? (s(), r("div", xt, " Click a block above to add it ")) : q("", !0)
                ]),
                J.value ? (s(), r("div", _t, [
                  (s(), P(qe, {
                    key: J.value.id,
                    block: J.value,
                    onUpdate: se
                  }, null, 8, ["block"]))
                ])) : (s(), r("div", ht, " Select a block to configure it ")),
                t("div", kt, [
                  p(S, {
                    label: "Reset to Default",
                    variant: "plain",
                    size: "md",
                    onClick: me
                  })
                ])
              ]),
              t("div", wt, [
                p(Je, {
                  blocks: c.value,
                  "selected-block-id": v.value,
                  "template-type": _.value
                }, null, 8, ["blocks", "selected-block-id", "template-type"])
              ])
            ]))
          ]),
          _: 2
        }, [
          C.value === "editor" ? {
            name: "dialog-footer",
            fn: T(() => [
              t("div", Tt, [
                a.value ? (s(), P(S, {
                  key: 0,
                  label: "Delete Template",
                  variant: "destructive",
                  size: "md",
                  onClick: e[2] || (e[2] = (o) => w.value = !0)
                })) : q("", !0),
                p(S, {
                  label: "Save Template",
                  variant: "primary",
                  size: "md",
                  onClick: e[3] || (e[3] = (o) => y.value = !0)
                })
              ])
            ]),
            key: "0"
          } : void 0
        ]), 1032, ["modelValue"]),
        p(B, {
          modelValue: y.value,
          "onUpdate:modelValue": e[5] || (e[5] = (o) => y.value = o),
          overlay: !0,
          dismissAway: !0,
          "close-button": "",
          "max-width": "400px"
        }, {
          "dialog-header": T(() => e[11] || (e[11] = [
            t("span", null, "Save Print Template?", -1)
          ])),
          "dialog-footer": T(() => [
            p(S, {
              class: "ml-auto",
              label: "Save",
              variant: "primary",
              size: "md",
              loading: n.value,
              onClick: ce
            }, null, 8, ["loading"])
          ]),
          default: T(() => [
            t("div", Ft, [
              e[13] || (e[13] = t("p", null, "Are you sure you want to save this print template?", -1)),
              e[14] || (e[14] = t("p", { class: "text-gray-500 text-sm mt-2" }, " This template will be used for all future prints of this type. ", -1)),
              t("div", Dt, [
                p(u, {
                  name: "warning",
                  size: "sm"
                }),
                e[12] || (e[12] = t("span", null, "This will affect all locations under this business.", -1))
              ])
            ])
          ]),
          _: 1
        }, 8, ["modelValue"]),
        p(B, {
          modelValue: w.value,
          "onUpdate:modelValue": e[6] || (e[6] = (o) => w.value = o),
          overlay: !0,
          dismissAway: !0,
          "close-button": "",
          "max-width": "400px"
        }, {
          "dialog-header": T(() => e[15] || (e[15] = [
            t("span", null, "Delete Print Template?", -1)
          ])),
          "dialog-footer": T(() => [
            p(S, {
              class: "ml-auto",
              label: "Delete",
              variant: "destructive",
              size: "md",
              loading: n.value,
              onClick: pe
            }, null, 8, ["loading"])
          ]),
          default: T(() => [
            t("div", Ct, [
              e[17] || (e[17] = t("p", null, "Are you sure you want to delete this print template?", -1)),
              e[18] || (e[18] = t("p", { class: "text-gray-500 text-sm mt-2" }, " The default print layout will be used for all future prints. ", -1)),
              t("div", St, [
                p(u, {
                  name: "warning",
                  size: "sm"
                }),
                e[16] || (e[16] = t("span", null, "This will affect all locations under this business.", -1))
              ])
            ])
          ]),
          _: 1
        }, 8, ["modelValue"])
      ], 64);
    };
  }
}), Vt = { class: "p-16 flex flex-col gap-16" }, $t = { class: "bg-white rounded-8 p-16 shadow-sm" }, zt = { class: "fm-typo-en-heading-sm-600 text-fm-color-typo-primary mb-12" }, It = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary mb-16" }, Mt = /* @__PURE__ */ Y({
  __name: "SettingsView",
  setup(E) {
    const { t: x } = Ie(), g = Se();
    g.fetchTemplates();
    const f = b(!1);
    function h() {
      g.invalidate(), g.fetchTemplates();
    }
    function d() {
      f.value = !0;
    }
    return ($, i) => {
      const m = V("FmButton");
      return s(), P(_e, {
        title: O(x)("inventory.settings.title")
      }, {
        default: T(() => [
          t("div", Vt, [
            p(Oe, null, {
              default: T(() => [
                t("div", $t, [
                  t("h2", zt, F(O(x)("inventory.settings.printTemplate.title")), 1),
                  t("p", It, F(O(x)("inventory.settings.printTemplate.description")), 1),
                  p(m, {
                    onClick: d,
                    variant: "secondary",
                    label: O(x)("inventory.settings.printTemplate.edit")
                  }, null, 8, ["label"])
                ])
              ]),
              _: 1
            })
          ]),
          (s(), P(xe, { to: "body" }, [
            p(Bt, {
              modelValue: f.value,
              "onUpdate:modelValue": i[0] || (i[0] = (n) => f.value = n),
              onSaved: h
            }, null, 8, ["modelValue"])
          ]))
        ]),
        _: 1
      }, 8, ["title"]);
    };
  }
});
export {
  Mt as default
};
