import { S as _sfc_main$1, m as _sfc_main$2 } from "../ssr.js";
import _sfc_main$3 from "./QuickView-ChOqSPa5.js";
import { useForm } from "@inertiajs/vue3";
import { computed, createTextVNode, createVNode, ref, resolveComponent, toDisplayString, unref, useSSRContext, withCtx } from "vue";
import { useI18n } from "vue-i18n";
import { ssrIncludeBooleanAttr, ssrInterpolate, ssrRenderAttr, ssrRenderComponent } from "vue/server-renderer";
//#region resources/js/Pages/Sma/Order/Quotation/View.vue
var _sfc_main = {
	__name: "View",
	__ssrInlineRender: true,
	props: {
		quotation: {
			type: Object,
			required: true
		},
		hash: {
			type: String,
			default: null
		},
		custom_fields: {
			type: Array,
			default: () => []
		}
	},
	setup(__props) {
		const { t } = useI18n();
		const props = __props;
		const signaturePad = ref(null);
		const isAlreadySigned = computed(() => !!props.quotation.signed_at);
		const canSign = computed(() => !!props.hash && !isAlreadySigned.value);
		const form = useForm({
			signed_by_name: props.quotation.customer?.name ?? "",
			signature: null
		});
		return (_ctx, _push, _parent, _attrs) => {
			const _component_Head = resolveComponent("Head");
			_push(`<!--[-->`);
			_push(ssrRenderComponent(_component_Head, null, {
				default: withCtx((_, _push, _parent, _scopeId) => {
					if (_push) _push(`<title${_scopeId}>${ssrInterpolate(_ctx.$t("Quotation"))}</title>`);
					else return [createVNode("title", null, toDisplayString(_ctx.$t("Quotation")), 1)];
				}),
				_: 1
			}, _parent));
			_push(`<div class="p-6"><div class="relative mx-auto w-full max-w-3xl rounded-lg border border-gray-200 dark:border-gray-700 print:border-0">`);
			_push(ssrRenderComponent(_sfc_main$3, {
				current: __props.quotation,
				fields: __props.custom_fields,
				xfetch: true
			}, null, _parent));
			_push(`<div class="border-t border-gray-200 px-6 pb-6 dark:border-gray-700 print:hidden">`);
			if (isAlreadySigned.value) _push(`<div class="mt-6"><h3 class="mb-3 text-sm font-semibold text-gray-700 dark:text-gray-300">${ssrInterpolate(_ctx.$t("Customer Approval"))}</h3><div class="rounded-md border border-green-200 bg-green-50 p-4 dark:border-green-800 dark:bg-green-900/20"><div class="flex items-start gap-2 text-green-700 dark:text-green-400"><svg xmlns="http://www.w3.org/2000/svg" class="size-5 shrink-0" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"></path></svg><div><div class="text-sm font-medium">${ssrInterpolate(_ctx.$t("Approved by {name}", { name: __props.quotation.signed_by_name }))}</div><p class="mt-1 text-xs text-green-600 dark:text-green-500">${ssrInterpolate(_ctx.$datetime(__props.quotation.signed_at))}</p></div></div></div><div class="mt-4 rounded-md border border-gray-200 bg-white p-3 dark:border-gray-600 dark:bg-gray-50"><img${ssrRenderAttr("src", __props.quotation.signature)} alt="Customer Signature" class="max-h-32 w-auto"></div></div>`);
			else if (canSign.value) {
				_push(`<div class="mt-6"><h3 class="mb-1 text-sm font-semibold text-gray-700 dark:text-gray-300">${ssrInterpolate(_ctx.$t("Approve Quotation"))}</h3><p class="mb-4 text-xs text-gray-500">${ssrInterpolate(_ctx.$t("Sign below to approve and accept this quotation."))}</p><form class="space-y-4"><div><label class="mb-1 block text-xs font-medium text-gray-700 dark:text-gray-300">${ssrInterpolate(_ctx.$t("Full Name"))}</label>`);
				_push(ssrRenderComponent(unref(_sfc_main$1), {
					modelValue: unref(form).signed_by_name,
					"onUpdate:modelValue": ($event) => unref(form).signed_by_name = $event,
					placeholder: _ctx.$t("Enter your full name"),
					class: "w-full",
					required: ""
				}, null, _parent));
				if (unref(form).errors.signed_by_name) _push(`<p class="mt-1 text-xs text-red-500">${ssrInterpolate(unref(form).errors.signed_by_name)}</p>`);
				else _push(`<!---->`);
				_push(`</div><div><label class="mb-1 block text-xs font-medium text-gray-700 dark:text-gray-300">${ssrInterpolate(_ctx.$t("Signature"))}</label>`);
				_push(ssrRenderComponent(unref(_sfc_main$2), {
					ref_key: "signaturePad",
					ref: signaturePad,
					modelValue: unref(form).signature,
					"onUpdate:modelValue": ($event) => unref(form).signature = $event
				}, {
					placeholder: withCtx((_, _push, _parent, _scopeId) => {
						if (_push) _push(`${ssrInterpolate(_ctx.$t("Please draw your signature here"))}`);
						else return [createTextVNode(toDisplayString(_ctx.$t("Please draw your signature here")), 1)];
					}),
					clear: withCtx((_, _push, _parent, _scopeId) => {
						if (_push) _push(`${ssrInterpolate(_ctx.$t("Clear"))}`);
						else return [createTextVNode(toDisplayString(_ctx.$t("Clear")), 1)];
					}),
					_: 1
				}, _parent));
				if (unref(form).errors.signature) _push(`<p class="mt-1 text-xs text-red-500">${ssrInterpolate(unref(form).errors.signature)}</p>`);
				else _push(`<!---->`);
				_push(`</div><button type="submit"${ssrIncludeBooleanAttr(unref(form).processing || !unref(form).signature || !unref(form).signed_by_name) ? " disabled" : ""} class="inline-flex items-center rounded-md bg-green-600 px-4 py-2 text-sm font-semibold text-white shadow-sm transition hover:bg-green-700 disabled:cursor-not-allowed disabled:opacity-50">`);
				if (unref(form).processing) _push(`<svg class="mr-2 -ml-1 size-4 animate-spin" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"></path></svg>`);
				else _push(`<!---->`);
				_push(` ${ssrInterpolate(_ctx.$t("Approve & Sign"))}</button></form></div>`);
			} else _push(`<!---->`);
			_push(`</div>`);
			if (isAlreadySigned.value) _push(`<div class="hidden px-6 pb-6 print:block"><div class="mt-4 border-t border-gray-300 pt-4"><p class="text-xs font-semibold text-gray-600">${ssrInterpolate(_ctx.$t("Approved by"))}: ${ssrInterpolate(__props.quotation.signed_by_name)}</p><img${ssrRenderAttr("src", __props.quotation.signature)} alt="Customer Signature" class="mt-2 max-h-24 w-auto"></div></div>`);
			else _push(`<!---->`);
			_push(`</div></div><!--]-->`);
		};
	}
};
var _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
	const ssrContext = useSSRContext();
	(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("resources/js/Pages/Sma/Order/Quotation/View.vue");
	return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
//#endregion
export { _sfc_main as default };
