import e from "../PlTooltip/PlTooltip.js";
import "../PlTooltip/index.js";
import { getErrorMessage as t } from "../../helpers/error.js";
import n from "../PlSvg/PlSvg.js";
import "../PlSvg/index.js";
import r from "../PlIcon24/PlIcon24.js";
import "../PlIcon24/index.js";
import i from "../PlIcon16/PlIcon16.js";
import a from "../../utils/DoubleContour.js";
import { useLabelNotch as o } from "../../utils/useLabelNotch.js";
import "../PlIcon16/index.js";
import s from "../../assets/images/required.js";
import './pl-text-field.css';/* empty css              */
import { computed as c, createBlock as l, createCommentVNode as u, createElementBlock as d, createElementVNode as f, createVNode as p, defineComponent as m, mergeModels as h, normalizeClass as g, openBlock as _, ref as v, renderSlot as y, toDisplayString as b, unref as x, useModel as S, useSlots as C, vModelDynamic as w, withCtx as T, withDirectives as E, withModifiers as D } from "vue";
var O = { class: "pl-text-field__envelope" }, k = {
	key: 0,
	ref: "label"
}, A = {
	key: 1,
	class: "pl-text-field__prefix"
}, j = [
	"disabled",
	"placeholder",
	"type"
], M = {
	key: 0,
	class: "pl-text-field__error"
}, N = {
	key: 1,
	class: "pl-text-field__helper"
}, P = /* @__PURE__ */ m({
	name: "PlTextField",
	props: /* @__PURE__ */ h({
		label: {},
		clearable: { type: Function },
		required: {},
		error: {},
		helper: {},
		placeholder: {},
		disabled: { type: Boolean },
		dashed: { type: Boolean },
		prefix: {},
		validate: { type: Function },
		type: {},
		groupPosition: {}
	}, {
		modelValue: { required: !0 },
		modelModifiers: {}
	}),
	emits: ["update:modelValue"],
	setup(m) {
		let h = C(), P = S(m, "modelValue"), F = m, I = v(void 0), L = v(), R = v(!1), z = c(() => F.type && F.type === "password" ? R.value ? "text" : F.type : "text"), B = c(() => R.value ? "view-show" : "view-hide"), V = () => {
			F.clearable && (P.value = typeof F.clearable == "function" ? F.clearable() : "");
		}, H = c(() => P.value === ""), U = c(() => {
			let e = [], n = t(F.error);
			if (n && e.push(n), F.validate) {
				let t = F.validate(P.value);
				t && e.push(t);
			}
			return F.required && H.value && e.push("Value is required"), e;
		}), W = c(() => U.value.length > 0), G = c(() => F.clearable && !H.value && F.type !== "password" && !F.disabled), K = () => R.value = !R.value, q = () => L.value?.focus();
		return o(I), (t, o) => (_(), d("div", O, [f("div", {
			ref_key: "rootRef",
			ref: I,
			class: g(["pl-text-field", {
				error: W.value,
				disabled: m.disabled,
				dashed: m.dashed,
				nonEmpty: !H.value
			}])
		}, [
			m.label ? (_(), d("label", k, [
				m.required ? (_(), l(x(n), {
					key: 0,
					uri: x(s)
				}, null, 8, ["uri"])) : u("", !0),
				f("span", null, b(m.label), 1),
				x(h).tooltip ? (_(), l(x(e), {
					key: 1,
					class: "info",
					position: "top"
				}, {
					tooltip: T(() => [y(t.$slots, "tooltip")]),
					_: 3
				})) : u("", !0)
			], 512)) : u("", !0),
			m.prefix ? (_(), d("div", A, b(m.prefix), 1)) : u("", !0),
			E(f("input", {
				ref_key: "inputRef",
				ref: L,
				"onUpdate:modelValue": o[0] ||= (e) => P.value = e,
				disabled: m.disabled,
				placeholder: m.placeholder || "...",
				type: z.value,
				spellcheck: "false"
			}, null, 8, j), [[w, P.value]]),
			f("div", {
				class: "pl-text-field__append",
				onClick: q
			}, [
				G.value ? (_(), l(x(i), {
					key: 0,
					class: "pl-text-field__clearable",
					name: "delete-clear",
					onClick: D(V, ["stop"])
				})) : u("", !0),
				m.type === "password" ? (_(), l(x(r), {
					key: 1,
					name: B.value,
					style: { cursor: "pointer" },
					onClick: D(K, ["stop"])
				}, null, 8, ["name"])) : u("", !0),
				y(t.$slots, "append")
			]),
			p(a, {
				class: "pl-text-field__contour",
				"group-position": m.groupPosition
			}, null, 8, ["group-position"])
		], 2), W.value ? (_(), d("div", M, b(U.value.join(" ")), 1)) : m.helper ? (_(), d("div", N, b(m.helper), 1)) : u("", !0)]));
	}
});
export { P as default };

//# sourceMappingURL=PlTextField.vue2.js.map