import { a as _sfc_main$7, i as _sfc_main$1, n as _sfc_main$3, o as _sfc_main$4, r as _sfc_main$6, s as _sfc_main$5, t as _sfc_main$2, x as _sfc_main$8, z as http_default } from "../ssr.js";
import { usePage } from "@inertiajs/vue3";
import { Fragment, createBlock, createCommentVNode, createTextVNode, createVNode, mergeProps, onMounted, openBlock, ref, resolveDynamicComponent, toDisplayString, unref, useSSRContext, withCtx } from "vue";
import { ssrInterpolate, ssrRenderAttrs, ssrRenderComponent, ssrRenderVNode } from "vue/server-renderer";
//#region resources/js/Pages/Sma/Order/Delivery/QuickView.vue
var _sfc_main = {
	__name: "QuickView",
	__ssrInlineRender: true,
	props: [
		"current",
		"custom_fields",
		"editRow",
		"xfetch"
	],
	setup(__props) {
		const page = usePage();
		const props = __props;
		const loading = ref(true);
		const delivery = ref(null);
		const templateComponent = {
			One: _sfc_main$1,
			Two: _sfc_main$2,
			Three: _sfc_main$3,
			Four: _sfc_main$4,
			Five: _sfc_main$5,
			Six: _sfc_main$6,
			Minimal: _sfc_main$7
		};
		onMounted(async () => {
			if (props.xfetch) {
				delivery.value = props.current;
				loading.value = false;
			} else await http_default.get(route("deliveries.show", {
				delivery: props.current.id,
				json: true
			})).then((res) => {
				delivery.value = res.data;
				loading.value = false;
			}).catch(() => loading.value = false);
		});
		return (_ctx, _push, _parent, _attrs) => {
			if (loading.value) {
				_push(`<div${ssrRenderAttrs(mergeProps({ class: "relative h-64" }, _attrs))}>`);
				_push(ssrRenderComponent(unref(_sfc_main$8), null, null, _parent));
				_push(`</div>`);
			} else if (delivery.value) ssrRenderVNode(_push, createVNode(resolveDynamicComponent(templateComponent[unref(page).props.settings?.sale_template || "One"]), mergeProps({
				type: "delivery",
				xfetch: __props.xfetch,
				record: delivery.value,
				editRow: __props.editRow,
				custom_fields: __props.custom_fields
			}, _attrs), {
				"header-extra": withCtx((_, _push, _parent, _scopeId) => {
					if (_push) _push(`<div class="flex gap-1 text-sm"${_scopeId}>${ssrInterpolate(_ctx.$t("Sale Reference"))}: <p class="truncate hover:text-clip print:block print:text-clip" dir="rtl"${_scopeId}>${ssrInterpolate(delivery.value.sale?.reference)}</p></div>`);
					else return [createVNode("div", { class: "flex gap-1 text-sm" }, [createTextVNode(toDisplayString(_ctx.$t("Sale Reference")) + ": ", 1), createVNode("p", {
						class: "truncate hover:text-clip print:block print:text-clip",
						dir: "rtl"
					}, toDisplayString(delivery.value.sale?.reference), 1)])];
				}),
				amount: withCtx(({ record }, _push, _parent, _scopeId) => {
					if (_push) {
						_push(`<div class="mx-4 mb-4 rounded-md border border-gray-200 bg-gray-50 px-5 py-4 dark:border-gray-700 dark:bg-gray-950"${_scopeId}><div class="text-sm font-bold"${_scopeId}>${ssrInterpolate(_ctx.$t("Address"))}:</div><div class="text-lg font-semibold"${_scopeId}>${ssrInterpolate(record.address?.company || record.address?.name)}</div>`);
						if (record.address?.company) _push(`<div class="text-lg font-semibold"${_scopeId}>${ssrInterpolate(_ctx.$t("Attn"))}: ${ssrInterpolate(record.address?.name)}</div>`);
						else _push(`<!---->`);
						_push(`<div class="flex gap-1 text-lg"${_scopeId}><span${_scopeId}>${ssrInterpolate(_ctx.$address(record.address))}</span></div>`);
						if (record.delivered_at) _push(`<!--[--><div class="mt-1"${_scopeId}>${ssrInterpolate(_ctx.$t("Delivered at"))}: <span class="font-bold"${_scopeId}>${ssrInterpolate(_ctx.$datetime(record.delivered_at))}</span></div><div class="mt-1"${_scopeId}>${ssrInterpolate(_ctx.$t("Delivered by"))}: <span class="font-bold"${_scopeId}>${ssrInterpolate(record.delivered_by || "")}</span></div><div class="mt-1"${_scopeId}>${ssrInterpolate(_ctx.$t("Received by"))}: <span class="font-bold"${_scopeId}>${ssrInterpolate(record.received_by || "")}</span></div><!--]-->`);
						else _push(`<!---->`);
						_push(`</div>`);
					} else return [createVNode("div", { class: "mx-4 mb-4 rounded-md border border-gray-200 bg-gray-50 px-5 py-4 dark:border-gray-700 dark:bg-gray-950" }, [
						createVNode("div", { class: "text-sm font-bold" }, toDisplayString(_ctx.$t("Address")) + ":", 1),
						createVNode("div", { class: "text-lg font-semibold" }, toDisplayString(record.address?.company || record.address?.name), 1),
						record.address?.company ? (openBlock(), createBlock("div", {
							key: 0,
							class: "text-lg font-semibold"
						}, toDisplayString(_ctx.$t("Attn")) + ": " + toDisplayString(record.address?.name), 1)) : createCommentVNode("", true),
						createVNode("div", { class: "flex gap-1 text-lg" }, [createVNode("span", null, toDisplayString(_ctx.$address(record.address)), 1)]),
						record.delivered_at ? (openBlock(), createBlock(Fragment, { key: 1 }, [
							createVNode("div", { class: "mt-1" }, [createTextVNode(toDisplayString(_ctx.$t("Delivered at")) + ": ", 1), createVNode("span", { class: "font-bold" }, toDisplayString(_ctx.$datetime(record.delivered_at)), 1)]),
							createVNode("div", { class: "mt-1" }, [createTextVNode(toDisplayString(_ctx.$t("Delivered by")) + ": ", 1), createVNode("span", { class: "font-bold" }, toDisplayString(record.delivered_by || ""), 1)]),
							createVNode("div", { class: "mt-1" }, [createTextVNode(toDisplayString(_ctx.$t("Received by")) + ": ", 1), createVNode("span", { class: "font-bold" }, toDisplayString(record.received_by || ""), 1)])
						], 64)) : createCommentVNode("", true)
					])];
				}),
				_: 1
			}), _parent);
			else _push(`<div${ssrRenderAttrs(mergeProps({ class: "flex min-h-64 items-center justify-center p-6 text-lg font-thin" }, _attrs))}>${ssrInterpolate(_ctx.$t("No data found, the record might not belong to the selected store."))}</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/Delivery/QuickView.vue");
	return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
//#endregion
export { _sfc_main as default };
