import { defineComponent as b, computed as D, openBlock as k, createBlock as C } from "vue";
import { ac as p, c8 as v, bf as F } from "./main-CI6Q9nmO.js";
const V = /* @__PURE__ */ b({
  __name: "DateFilter",
  props: {
    header: {
      type: Object,
      required: !0
    },
    filters: {
      type: Array,
      default: () => []
    },
    filterValue: {
      type: [String, Date, Object, null],
      default: null
    },
    inputConfig: {
      type: Object,
      default: () => ({})
    },
    disableErrorHandling: {
      type: Boolean,
      default: !1
    },
    variant: {
      type: String,
      default: "outlined"
    },
    hideDetails: {
      type: Boolean,
      default: !0
    },
    density: {
      type: String,
      default: "compact"
    },
    backgroundColor: {
      type: String,
      default: "white"
    },
    clearable: {
      type: Boolean,
      default: !0
    },
    headingLevel: {
      type: Number,
      default: 4
    }
  },
  emits: ["update:filters"],
  setup(e, { emit: g }) {
    const { parseDate: y } = v(), t = e, u = g;
    function s() {
      return String(t.header.key || t.header.value || (t.header.title ? `filter_${t.header.title}` : `filter_${Date.now()}`));
    }
    const f = D({
      get: () => t.filterValue,
      set: (a) => {
        const l = s();
        if (!l) return;
        if (a === null) {
          const r = t.filters.filter((o) => o.key !== l);
          u("update:filters", r);
          return;
        }
        const i = t.filters.findIndex((r) => r.key === l), n = [...t.filters];
        let d = a;
        typeof a == "string" && a.trim() !== "" && y(a, t.header.dateFormat || "DD/MM/YYYY") && (d = a), n[i] ? n[i].value = d : n.push({
          key: l,
          value: d,
          type: "date"
        }), u("update:filters", n);
      }
    });
    function h() {
      const a = s(), l = t.filters.filter((i) => i.key !== a);
      u("update:filters", l);
    }
    return (a, l) => {
      var i, n, d, r, o, c;
      return k(), C(p, {
        modelValue: f.value,
        "onUpdate:modelValue": l[0] || (l[0] = (m) => f.value = m),
        label: e.header.title || "Sélectionner une date",
        "heading-level": e.headingLevel,
        clearable: ((i = e.inputConfig) == null ? void 0 : i.clearable) ?? e.clearable,
        density: ((n = e.inputConfig) == null ? void 0 : n.density) ?? e.density,
        "hide-details": ((d = e.inputConfig) == null ? void 0 : d.hideDetails) ?? e.hideDetails,
        "hide-messages": e.header.hideMessages,
        variant: ((r = e.inputConfig) == null ? void 0 : r.variant) ?? e.variant,
        "disable-error-handling": ((o = e.inputConfig) == null ? void 0 : o.disableErrorHandling) ?? e.disableErrorHandling,
        "bg-color": ((c = e.inputConfig) == null ? void 0 : c.backgroundColor) ?? e.backgroundColor,
        format: e.header.dateFormat,
        class: "filter-input",
        "onClick:clear": h
      }, null, 8, ["modelValue", "label", "heading-level", "clearable", "density", "hide-details", "hide-messages", "variant", "disable-error-handling", "bg-color", "format"]);
    };
  }
}), w = /* @__PURE__ */ F(V, [["__scopeId", "data-v-d78d05fe"]]);
export {
  w as default
};
