import { defineComponent as q, mergeModels as I, useModel as T, computed as r, resolveComponent as h, createBlock as P, renderSlot as m, createCommentVNode as $, unref as l, openBlock as S, mergeProps as s, createVNode as c } from "vue";
import { S as x } from "./contacts-BuM4ADEC.js";
import "./index-CX-np8_F.js";
import "lodash-es";
import "@aliasedDeps/api-services/axios";
import { B as N, ah as W, ai as V, aj as E } from "./install-DJFUeaKV.js";
const a = {
  Text: "string",
  Number: "int32",
  Select: "lookup",
  Multiselect: "list",
  Calendar: "datetime",
  Boolean: "bool"
}, F = /* @__PURE__ */ q({
  __name: "wt-type-extension-value-input",
  props: /* @__PURE__ */ I({
    field: {},
    label: {},
    required: { type: Boolean },
    v: {}
  }, {
    modelValue: {},
    modelModifiers: {}
  }),
  emits: ["update:modelValue"],
  setup(u) {
    const f = T(u, "modelValue"), n = u;
    n.v?.$touch();
    const { t: B } = N(), C = r(() => n.label || B(n.field?.name || "vocabulary.labels")), M = r(() => n.required ?? n.field.required), o = r(() => f.value), t = r(() => ({
      label: C.value,
      required: M.value,
      v: n.v
    })), k = r(() => ({
      clearable: !0,
      trackBy: "id",
      searchMethod: () => b(n.field.lookup)
    })), y = r(() => ({
      ...k.value,
      multiple: !0
    })), d = (e) => {
      f.value = e;
    }, b = ({ path: e, display: i, primary: v }) => (p) => x.getSysTypeRecordsLookup({
      ...p,
      path: e,
      display: i,
      primary: v
    }), w = (e) => {
      if (Object.values(e).length === 0)
        return d(null);
      d({
        id: e.id,
        name: e.name
      });
    }, g = (e) => {
      d(
        e.map((i) => ({
          id: i.id,
          name: i.name
        }))
      );
    };
    return (e, i) => {
      const v = h("wt-input-text"), p = h("wt-input-number");
      return u.field.kind === l(a).Text ? (S(), P(v, s({ key: 0 }, t.value, {
        "model-value": o.value,
        "onUpdate:modelValue": d
      }), null, 16, ["model-value"])) : u.field.kind === l(a).Number ? (S(), P(p, s({ key: 1 }, t.value, {
        "model-value": o.value,
        "onUpdate:modelValue": d
      }), null, 16, ["model-value"])) : u.field.kind === l(a).Boolean ? m(e.$slots, l(a).Boolean, {
        key: 2,
        defaultProps: { ...t.value }
      }, () => [
        c(l(W), s(t.value, {
          "model-value": o.value,
          "onUpdate:modelValue": d
        }), null, 16, ["model-value"])
      ]) : u.field.kind === l(a).Select ? m(e.$slots, l(a).Select, {
        key: 3,
        defaultProps: {
          ...t.value,
          ...k.value,
          value: o.value
        }
      }, () => [
        c(l(V), s(t.value, {
          value: o.value,
          "search-method": b(u.field.lookup),
          "track-by": "id",
          clearable: "",
          onInput: w
        }), null, 16, ["value", "search-method"])
      ]) : u.field.kind === l(a).Multiselect ? m(e.$slots, l(a).Multiselect, {
        key: 4,
        defaultProps: {
          ...t.value,
          ...y.value,
          value: o.value
        }
      }, () => [
        c(l(V), s({ ...t.value, ...y.value }, {
          value: o.value,
          onInput: g
        }), null, 16, ["value"])
      ]) : u.field.kind === l(a).Calendar ? m(e.$slots, l(a).Calendar, {
        key: 5,
        defaultProps: {
          ...t.value,
          value: o.value
        }
      }, () => [
        c(l(E), s(t.value, {
          value: o.value,
          mode: "datetime",
          onInput: d
        }), null, 16, ["value"])
      ]) : $("", !0);
    };
  }
});
export {
  F as default
};
