import { t as e } from "./_plugin-vue_export-helper-B3ysoDQm.js";
import { d as t, f as n, l as r, r as i } from "./enums-De8CDKZ1.js";
import { a, i as o, n as s, r as c, t as l } from "./toZonedTime-B8L5kbse.js";
import { t as u } from "./vue-i18n-Db_oYfO8.js";
import { t as d } from "./useValidation-DGl2otXJ.js";
import { computed as f, createBlock as p, createCommentVNode as m, createElementBlock as ee, createElementVNode as h, createTextVNode as g, createVNode as _, defineComponent as v, guardReactiveProps as y, mergeModels as b, mergeProps as x, nextTick as S, normalizeProps as C, onMounted as w, onUnmounted as T, openBlock as E, renderSlot as D, resolveComponent as O, toDisplayString as k, toRefs as A, unref as j, useModel as M, useTemplateRef as N, vShow as P, withCtx as F, withDirectives as I } from "vue";
import L from "primevue/datepicker";
//#region node_modules/date-fns-tz/dist/esm/fromZonedTime/index.js
function R(e, t, n) {
	if (typeof e == "string" && !e.match(c)) return s(e, {
		...n,
		timeZone: t
	});
	e = s(e, n);
	let r = a(e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), e.getMinutes(), e.getSeconds(), e.getMilliseconds()).getTime(), i = o(t, new Date(r));
	return new Date(r + i);
}
//#endregion
//#region src/components/wt-datepicker/_internals/composables/useOverlayAnchor.ts
function z() {
	let e = null;
	function t(e, t) {
		e.style.width !== t && (e.style.width = t, e.style.minWidth = "");
	}
	function n(e, t, n) {
		e.style.transformOrigin !== t && (e.style.transformOrigin = t, e.style.top = n);
	}
	function r(r) {
		e?.disconnect();
		let i = r.style.width, a = r.style.transformOrigin, o = r.style.top;
		e = new MutationObserver(() => {
			t(r, i), n(r, a, o);
		}), e.observe(r, {
			attributes: !0,
			attributeFilter: ["style"]
		});
	}
	function i() {
		e?.disconnect(), e = null;
	}
	return T(i), {
		lock: r,
		unlock: i
	};
}
//#endregion
//#region src/components/wt-datepicker/_internals/composables/usePreventZeroPad.ts
function B(e) {
	let t = null;
	function n(e) {
		let n = e.target, r = n.value, i = n.selectionStart ?? 0, a = r.split("/"), o = 0;
		for (let e = 0; e < Math.min(a.length, 2); e++) {
			let n = a[e], s = o + n.length;
			if (i <= s && n.length === 1 && /^\d$/.test(n)) {
				t = {
					value: r,
					cursor: i
				};
				return;
			}
			o = s + 1;
		}
	}
	function r(e) {
		if (!t) return;
		let n = e.target, { value: r, cursor: i } = t;
		t = null, n.value !== r && (n.value = r, n.setSelectionRange(i, i), e.stopImmediatePropagation());
	}
	w(() => {
		let t = e();
		t && (t.addEventListener("input", n, { capture: !0 }), t.addEventListener("input", r));
	}), T(() => {
		let t = e();
		t && (t.removeEventListener("input", n, { capture: !0 }), t.removeEventListener("input", r));
	});
}
//#endregion
//#region src/components/wt-datepicker/_internals/composables/useRestoreOnBlur.ts
function V(e, t) {
	function n() {
		if (t()) return;
		let n = e();
		n && n.rawValue === null && S(() => {
			n.updateModel(/* @__PURE__ */ new Date());
		});
	}
	return { onBlur: n };
}
//#endregion
//#region src/components/wt-datepicker/wt-datepicker.vue?vue&type=script&setup=true&lang.ts
var H = { class: "wt-datepicker" }, U = { class: "wt-datepicker__button-bar" }, W = [
	"onMousedown",
	"onMouseup",
	"onMouseleave"
], G = [
	"onMousedown",
	"onMouseup",
	"onMouseleave"
], K = [
	"onMousedown",
	"onMouseup",
	"onMouseleave"
], q = [
	"onMousedown",
	"onMouseup",
	"onMouseleave"
], J = /*#__PURE__*/ e(/* @__PURE__ */ v({
	__name: "wt-datepicker",
	props: /*@__PURE__*/ b({
		showTime: { type: Boolean },
		minDate: {},
		maxDate: {},
		label: {},
		labelProps: { default: () => ({}) },
		placholder: {},
		disabled: { type: Boolean },
		required: { type: Boolean },
		clearable: { type: Boolean },
		timezone: {},
		v: {},
		customValidators: { default: () => [] },
		modelValue: {},
		defaultValue: {},
		name: {},
		selectionMode: {},
		dateFormat: {},
		updateModelType: {},
		inline: { type: Boolean },
		showOtherMonths: { type: Boolean },
		selectOtherMonths: { type: Boolean },
		showIcon: { type: Boolean },
		iconDisplay: {},
		icon: {},
		prevIcon: {},
		nextIcon: {},
		incrementIcon: {},
		decrementIcon: {},
		numberOfMonths: {},
		responsiveOptions: {},
		breakpoint: {},
		view: {},
		disabledDates: {},
		disabledDays: {},
		maxDateCount: {},
		showOnFocus: { type: Boolean },
		autoZIndex: { type: Boolean },
		baseZIndex: {},
		showButtonBar: { type: Boolean },
		shortYearCutoff: {},
		timeOnly: { type: Boolean },
		hourFormat: {},
		stepHour: {},
		stepMinute: {},
		stepSecond: {},
		showSeconds: { type: Boolean },
		hideOnDateTimeSelect: { type: Boolean },
		hideOnRangeSelection: { type: Boolean },
		timeSeparator: {},
		showWeek: { type: Boolean },
		manualInput: { type: Boolean },
		showClear: { type: Boolean },
		size: {},
		invalid: { type: Boolean },
		variant: {},
		readonly: { type: Boolean },
		placeholder: {},
		appendTo: {},
		inputId: {},
		inputStyle: {},
		inputClass: {},
		panelStyle: {},
		panelClass: {},
		todayButtonProps: {},
		clearButtonProps: {},
		navigatorButtonProps: {},
		timepickerButtonProps: {},
		fluid: { type: Boolean },
		ariaLabelledby: {},
		ariaLabel: {},
		formControl: {},
		dt: {},
		pt: {},
		ptOptions: {},
		unstyled: { type: Boolean }
	}, {
		modelValue: { default: null },
		modelModifiers: {}
	}),
	emits: /*@__PURE__*/ b([
		"update:modelValue",
		"value-change",
		"input",
		"date-select",
		"show",
		"hide",
		"today-click",
		"clear-click",
		"month-change",
		"year-change",
		"focus",
		"blur",
		"keydown"
	], ["update:modelValue"]),
	setup(e, { emit: a }) {
		let o = e, s = M(e, "modelValue"), { t: c } = u(), v = f({
			get() {
				if (!s.value) return null;
				let e = /* @__PURE__ */ new Date(+s.value);
				return o.timezone ? l(e, o.timezone) : e;
			},
			set(e) {
				if (!e) {
					if (!o.clearable) return;
					s.value = null;
					return;
				}
				let t = o.timezone ? R(e, o.timezone) : e;
				s.value = t.getTime();
			}
		}), b = N("datepicker"), w = `datepicker-${Math.random().toString(36).slice(2, 11)}`;
		B(() => b.value?.$el?.querySelector("input"));
		let { onBlur: T } = V(() => b.value, () => !!o.clearable), J = f(() => o.placholder || `dd/mm/yyyy ${o.showTime ? "hh:mm" : ""}`), { lock: Y, unlock: X } = z(), Z = () => {
			if (o.showTime && v.value) {
				let e = v.value;
				S(() => {
					v.value = new Date(e.getTime());
				});
			}
			setTimeout(() => {
				b.value?.alignOverlay();
				let e = b.value?.overlay;
				e && (e.style.minWidth = "", Y(e));
			}, 0);
		}, Q = () => {
			X();
		}, te = f(() => o.required ? `${o.label}*` : o.label), { v: ne, customValidators: re } = A(o), { isValidation: ie, invalid: ae, validationText: $, validationTextColor: oe } = d({
			v: ne,
			customValidators: re
		});
		return (a, o) => {
			let s = O("wt-label"), l = O("wt-button"), u = O("wt-icon-btn"), d = O("wt-message");
			return E(), ee("div", H, [
				_(s, x(e.labelProps, { disabled: e.disabled }, {
					for: w,
					invalid: j(ae)
				}), {
					default: F(() => [D(a.$slots, "label", C(y({ label: e.label })), () => [g(k(te.value), 1)], !0)], void 0, !0),
					_: 3
				}, 16, ["disabled", "invalid"]),
				_(j(L), {
					ref_key: "datepicker",
					ref: b,
					id: w,
					modelValue: v.value,
					"onUpdate:modelValue": o[0] ||= (e) => v.value = e,
					"date-format": "dd/mm/yy",
					"input-class": "typo-body-1",
					required: e.required,
					disabled: e.disabled,
					"show-time": e.showTime,
					"min-date": e.minDate,
					"max-date": e.maxDate,
					placeholder: J.value,
					"show-clear": e.clearable && v.value,
					"show-button-bar": "",
					fluid: "",
					pt: {
						selectMonth: { class: "typo-subtitle-1" },
						selectYear: { class: "typo-subtitle-1" },
						tableHeaderCell: { class: "typo-body-2-bold" },
						day: { class: "typo-body-2" },
						hour: { class: "typo-body-2" },
						minute: { class: "typo-body-2" },
						panel: { style: { maxWidth: "380px" } }
					},
					onShow: Z,
					onHide: Q,
					onBlur: j(T)
				}, {
					buttonbar: F(({ todayCallback: i, clearCallback: a }) => [h("div", U, [_(l, {
						color: j(n).SECONDARY,
						variant: j(t).OUTLINED,
						size: j(r).SM,
						onClick: i
					}, {
						default: F(() => [g(k(j(c)("reusable.today")), 1)], void 0, !0),
						_: 1
					}, 8, [
						"color",
						"variant",
						"size",
						"onClick"
					]), I(_(l, {
						color: j(n).SECONDARY,
						variant: j(t).OUTLINED,
						size: j(r).SM,
						onClick: a
					}, {
						default: F(() => [g(k(j(c)("reusable.clear")), 1)], void 0, !0),
						_: 1
					}, 8, [
						"color",
						"variant",
						"size",
						"onClick"
					]), [[P, e.clearable && v.value]])])]),
					prevbutton: F(({ actionCallback: e }) => [_(u, {
						icon: "arrow-left",
						onClick: e
					}, null, 8, ["onClick"])]),
					nextbutton: F(({ actionCallback: e }) => [_(u, {
						icon: "arrow-right",
						onClick: e
					}, null, 8, ["onClick"])]),
					clearicon: F(({ clearCallback: e }) => [_(u, {
						icon: "close",
						class: "wt-datepicker__clear-icon",
						onClick: e
					}, null, 8, ["onClick"])]),
					hourincrementbutton: F(({ callbacks: e }) => [h("span", {
						onMousedown: e.mousedown,
						onMouseup: e.mouseup,
						onMouseleave: e.mouseleave
					}, [_(u, { icon: "arrow-up" })], 40, W)]),
					hourdecrementbutton: F(({ callbacks: e }) => [h("span", {
						onMousedown: e.mousedown,
						onMouseup: e.mouseup,
						onMouseleave: e.mouseleave
					}, [_(u, { icon: "arrow-down" })], 40, G)]),
					minuteincrementbutton: F(({ callbacks: e }) => [h("span", {
						onMousedown: e.mousedown,
						onMouseup: e.mouseup,
						onMouseleave: e.mouseleave
					}, [_(u, { icon: "arrow-up" })], 40, K)]),
					minutedecrementbutton: F(({ callbacks: e }) => [h("span", {
						onMousedown: e.mousedown,
						onMouseup: e.mouseup,
						onMouseleave: e.mouseleave
					}, [_(u, { icon: "arrow-down" })], 40, q)]),
					_: 1
				}, 8, [
					"modelValue",
					"required",
					"disabled",
					"show-time",
					"min-date",
					"max-date",
					"placeholder",
					"show-clear",
					"onBlur"
				]),
				j(ie) && j($) ? (E(), p(d, {
					key: 0,
					color: j(oe),
					variant: j(i).SIMPLE,
					size: j(r).SM
				}, {
					default: F(() => [g(k(j($)), 1)], void 0, !0),
					_: 1
				}, 8, [
					"color",
					"variant",
					"size"
				])) : m("", !0)
			]);
		};
	}
}), [["__scopeId", "data-v-d1bf89b4"]]);
//#endregion
export { J as default };
