import * as vue from "vue";
import { defineComponent, mergeProps, unref, createVNode, resolveDynamicComponent, withCtx, renderSlot, useSSRContext } from "vue";
import { ssrRenderAttrs, ssrRenderAttr, ssrInterpolate, ssrRenderVNode, ssrRenderSlot } from "vue/server-renderer";
import "../mount.js";
import "path-browserify";
import "deepmerge";
import "fast-safe-stringify";
import "spark-md5";
import "is-plain-object";
import "js-cookie";
import "events";
import "http";
import "@medv/finder";
import "front-matter";
import "markdown-it";
import "markdown-it-anchor";
import "markdown-it-implicit-figures";
import "markdown-it-link-attributes";
import "markdown-it-video";
import "remove-markdown";
import { i as inputs } from "./index.2544f8a4.js";
import "body-parser";
import "dotenv";
import "compression";
import "serve-favicon";
import "serve-static";
import "html-minifier";
import "vite";
import "@vue/server-renderer";
import "fs";
import "enquirer";
import "semver";
import "glob";
import "minimist";
import "handlebars";
import "execa";
import "multer";
import "sharp";
import "@vitejs/plugin-vue";
import "express";
import "axios";
import "knex";
import "dompurify";
import "dayjs";
import "chalk";
import "dayjs/plugin/relativeTime.js";
import "dayjs/plugin/utc.js";
import "dayjs/plugin/timezone.js";
import "dayjs/plugin/updateLocale.js";
import "dayjs/plugin/weekOfYear.js";
import "nanoid";
import "prettyoutput";
import "consola";
import "validator";
import "@vueuse/head";
import "node-fetch";
import "vue-router";
import "jsonwebtoken";
import "fs-extra";
import "bcrypt";
import "knex-stringcase";
import "@sinclair/typebox";
import "nodemailer";
import "nodemailer-html-to-text";
import "@tailwindcss/forms";
import "unocss/vite";
import "@unocss/preset-icons";
import "nodemon";
const __default__ = {
  inheritAttrs: false
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...__default__,
  __name: "ElInput",
  __ssrInlineRender: true,
  props: {
    modelValue: {
      type: [String, Object, Array, Number, Date, Boolean],
      default: void 0
    },
    label: { type: String, default: "" },
    description: { type: String, default: "" },
    input: {
      type: [String, Object],
      default: void 0
    }
  },
  emits: ["update:modelValue"],
  setup(__props, { emit }) {
    const props = __props;
    const attrs = vue.useAttrs();
    const { class: _class, ...passAttrs } = attrs;
    const inputEl = vue.ref();
    const valid = vue.ref();
    const inputComponent = vue.computed(() => {
      if (props.input && typeof props.input == "string") {
        return inputs[props.input];
      } else {
        return props.input || "";
      }
    });
    const setValidity = async () => {
      var _a, _b;
      const el = (_a = inputEl.value) == null ? void 0 : _a.$el;
      if (el) {
        if ((el instanceof HTMLInputElement || el instanceof HTMLSelectElement) && el.checkValidity) {
          valid.value = el.checkValidity();
        } else if (el.querySelector) {
          const realEl = (_b = el.querySelector("input")) != null ? _b : el.querySelector("select");
          if (realEl && realEl.checkValidity) {
            valid.value = realEl.checkValidity();
          } else
            valid.value = true;
        }
      }
    };
    const updateValue = async (value) => {
      await setValidity();
      emit("update:modelValue", value);
    };
    vue.onMounted(() => {
      setTimeout(async () => {
        await setValidity();
      }, 300);
    });
    return (_ctx, _push, _parent, _attrs) => {
      _push(`<div${ssrRenderAttrs(mergeProps({
        key: __props.label,
        class: ["f-el-input space-y-1.5", [unref(valid) ? "valid" : "not-valid", unref(attrs).class]]
      }, _attrs))}>`);
      if (__props.label || __props.description) {
        _push(`<div class="flex justify-between text-input-label-size"><div class="text">`);
        if (__props.label) {
          _push(`<label class="font-medium"${ssrRenderAttr("for", unref(attrs).for)}>${ssrInterpolate(__props.label)}</label>`);
        } else {
          _push(`<!---->`);
        }
        if (__props.description) {
          _push(`<div class="text-sm text-slate-400">${ssrInterpolate(__props.description)}</div>`);
        } else {
          _push(`<!---->`);
        }
        _push(`</div></div>`);
      } else {
        _push(`<!---->`);
      }
      _push(`<div class="input-area">`);
      if (unref(inputComponent)) {
        ssrRenderVNode(_push, createVNode(resolveDynamicComponent(unref(inputComponent)), mergeProps({
          ref_key: "inputEl",
          ref: inputEl,
          "model-value": __props.modelValue
        }, passAttrs, {
          "onUpdate:modelValue": ($event) => updateValue($event)
        }), {
          default: withCtx((_, _push2, _parent2, _scopeId) => {
            if (_push2) {
              ssrRenderSlot(_ctx.$slots, "default", {}, null, _push2, _parent2, _scopeId);
            } else {
              return [
                renderSlot(_ctx.$slots, "default")
              ];
            }
          }),
          _: 3
        }), _parent);
      } else {
        ssrRenderSlot(_ctx.$slots, "default", {}, null, _push, _parent);
      }
      ssrRenderSlot(_ctx.$slots, "after", {}, null, _push, _parent);
      _push(`</div></div>`);
    };
  }
});
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("../ui/ElInput.vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
export {
  _sfc_main as default
};
