import { H as PageSearch, M as _sfc_main$3, k as _sfc_main$1, pt as _sfc_main$2, st as _sfc_main$5, v as _sfc_main$6, vt as _sfc_main$7, x as _sfc_main$4 } from "../ssr.js";
import { t as _sfc_main$8 } from "./AdminLayout-eZgRfDMK.js";
import _sfc_main$9 from "./Form-mta9lJrH.js";
import { router } from "@inertiajs/vue3";
import { createBlock, createCommentVNode, createTextVNode, createVNode, openBlock, ref, resolveComponent, toDisplayString, unref, useSSRContext, withCtx } from "vue";
import { ssrInterpolate, ssrRenderComponent, ssrRenderList } from "vue/server-renderer";
//#region resources/js/Pages/Sma/Accounting/AccountType/Index.vue
var _sfc_main = /* @__PURE__ */ Object.assign({ layout: _sfc_main$8 }, {
	__name: "Index",
	__ssrInlineRender: true,
	props: ["pagination"],
	setup(__props) {
		const add = ref(false);
		const current = ref(null);
		const deleted = ref(false);
		const deleting = ref(false);
		const { filters, searching, searchNow, sortBy } = PageSearch();
		function editRow(row) {
			current.value = row;
			add.value = true;
		}
		function deleteRow(row) {
			deleting.value = true;
			router.delete(route("account-types.destroy", row.id), {
				preserveScroll: true,
				onSuccess: () => deleted.value = row.id,
				onFinish: () => deleting.value = false
			});
		}
		function hideForm() {
			current.value = null;
			add.value = false;
		}
		return (_ctx, _push, _parent, _attrs) => {
			const _component_Head = resolveComponent("Head");
			const _component_Header = resolveComponent("Header");
			const _component_Icon = resolveComponent("Icon");
			_push(`<!--[-->`);
			_push(ssrRenderComponent(_component_Head, null, {
				default: withCtx((_, _push, _parent, _scopeId) => {
					if (_push) _push(`<title${_scopeId}>${ssrInterpolate(_ctx.$t("Account Types"))}</title>`);
					else return [createVNode("title", null, toDisplayString(_ctx.$t("Account Types")), 1)];
				}),
				_: 1
			}, _parent));
			_push(ssrRenderComponent(_component_Header, null, {
				subheading: withCtx((_, _push, _parent, _scopeId) => {
					if (_push) _push(`${ssrInterpolate(_ctx.$t("Please review the data below"))}`);
					else return [createTextVNode(toDisplayString(_ctx.$t("Please review the data below")), 1)];
				}),
				menu: withCtx((_, _push, _parent, _scopeId) => {
					if (_push) {
						_push(`<div class="flex items-center justify-center gap-4"${_scopeId}>`);
						if (_ctx.$can("create-account-types")) _push(ssrRenderComponent(unref(_sfc_main$1), {
							type: "button",
							onClick: ($event) => add.value = true
						}, {
							default: withCtx((_, _push, _parent, _scopeId) => {
								if (_push) _push(`${ssrInterpolate(_ctx.$t("Add {x}", { x: _ctx.$t("Account Type") }))}`);
								else return [createTextVNode(toDisplayString(_ctx.$t("Add {x}", { x: _ctx.$t("Account Type") })), 1)];
							}),
							_: 1
						}, _parent, _scopeId));
						else _push(`<!---->`);
						_push(ssrRenderComponent(unref(_sfc_main$2), {
							align: "right",
							width: "56",
							"auto-close": false
						}, {
							trigger: withCtx((_, _push, _parent, _scopeId) => {
								if (_push) {
									_push(`<button class="-m-2 flex items-center rounded-md p-2.5 transition duration-150 ease-in-out"${_scopeId}>`);
									_push(ssrRenderComponent(_component_Icon, {
										name: "funnel-o",
										size: "size-5"
									}, null, _parent, _scopeId));
									_push(`<span class="sr-only"${_scopeId}>${ssrInterpolate(_ctx.$t("Show Filters"))}</span></button>`);
								} else return [createVNode("button", { class: "-m-2 flex items-center rounded-md p-2.5 transition duration-150 ease-in-out" }, [createVNode(_component_Icon, {
									name: "funnel-o",
									size: "size-5"
								}), createVNode("span", { class: "sr-only" }, toDisplayString(_ctx.$t("Show Filters")), 1)])];
							}),
							content: withCtx((_, _push, _parent, _scopeId) => {
								if (_push) {
									_push(`<div class="px-4 py-2"${_scopeId}><div${_scopeId}>`);
									_push(ssrRenderComponent(unref(_sfc_main$3), {
										json: true,
										onChange: unref(searchNow),
										label: _ctx.$t("Trashed"),
										modelValue: unref(filters).trashed,
										"onUpdate:modelValue": ($event) => unref(filters).trashed = $event,
										placeholder: _ctx.$t("With Trashed"),
										suggestions: [
											{
												value: "not",
												label: _ctx.$t("Not Trashed")
											},
											{
												value: "with",
												label: _ctx.$t("With Trashed")
											},
											{
												value: "only",
												label: _ctx.$t("Only Trashed")
											}
										]
									}, null, _parent, _scopeId));
									_push(`</div></div>`);
								} else return [createVNode("div", { class: "px-4 py-2" }, [createVNode("div", null, [createVNode(unref(_sfc_main$3), {
									json: true,
									onChange: unref(searchNow),
									label: _ctx.$t("Trashed"),
									modelValue: unref(filters).trashed,
									"onUpdate:modelValue": ($event) => unref(filters).trashed = $event,
									placeholder: _ctx.$t("With Trashed"),
									suggestions: [
										{
											value: "not",
											label: _ctx.$t("Not Trashed")
										},
										{
											value: "with",
											label: _ctx.$t("With Trashed")
										},
										{
											value: "only",
											label: _ctx.$t("Only Trashed")
										}
									]
								}, null, 8, [
									"onChange",
									"label",
									"modelValue",
									"onUpdate:modelValue",
									"placeholder",
									"suggestions"
								])])])];
							}),
							_: 1
						}, _parent, _scopeId));
						_push(`</div>`);
					} else return [createVNode("div", { class: "flex items-center justify-center gap-4" }, [_ctx.$can("create-account-types") ? (openBlock(), createBlock(unref(_sfc_main$1), {
						key: 0,
						type: "button",
						onClick: ($event) => add.value = true
					}, {
						default: withCtx(() => [createTextVNode(toDisplayString(_ctx.$t("Add {x}", { x: _ctx.$t("Account Type") })), 1)]),
						_: 1
					}, 8, ["onClick"])) : createCommentVNode("", true), createVNode(unref(_sfc_main$2), {
						align: "right",
						width: "56",
						"auto-close": false
					}, {
						trigger: withCtx(() => [createVNode("button", { class: "-m-2 flex items-center rounded-md p-2.5 transition duration-150 ease-in-out" }, [createVNode(_component_Icon, {
							name: "funnel-o",
							size: "size-5"
						}), createVNode("span", { class: "sr-only" }, toDisplayString(_ctx.$t("Show Filters")), 1)])]),
						content: withCtx(() => [createVNode("div", { class: "px-4 py-2" }, [createVNode("div", null, [createVNode(unref(_sfc_main$3), {
							json: true,
							onChange: unref(searchNow),
							label: _ctx.$t("Trashed"),
							modelValue: unref(filters).trashed,
							"onUpdate:modelValue": ($event) => unref(filters).trashed = $event,
							placeholder: _ctx.$t("With Trashed"),
							suggestions: [
								{
									value: "not",
									label: _ctx.$t("Not Trashed")
								},
								{
									value: "with",
									label: _ctx.$t("With Trashed")
								},
								{
									value: "only",
									label: _ctx.$t("Only Trashed")
								}
							]
						}, null, 8, [
							"onChange",
							"label",
							"modelValue",
							"onUpdate:modelValue",
							"placeholder",
							"suggestions"
						])])])]),
						_: 1
					})])];
				}),
				default: withCtx((_, _push, _parent, _scopeId) => {
					if (_push) _push(`${ssrInterpolate(_ctx.$t("Account Types"))} `);
					else return [createTextVNode(toDisplayString(_ctx.$t("Account Types")) + " ", 1)];
				}),
				_: 1
			}, _parent));
			_push(`<div class="relative flex grow flex-col items-stretch justify-stretch self-stretch bg-white px-4 sm:px-6 lg:px-8 dark:bg-gray-800">`);
			if (unref(searching)) _push(ssrRenderComponent(unref(_sfc_main$4), { "circle-size": "w-10 h-10" }, null, _parent));
			else _push(`<!---->`);
			_push(`<div class="flow-root grow"><div class="-mx-4 -my-2 overflow-x-auto sm:-mx-6 lg:-mx-8"><div class="my-2 inline-block min-w-full border-b border-gray-200 align-middle dark:border-gray-700"><table class="fixed-actions min-w-full divide-y divide-gray-200 dark:divide-gray-700"><thead><tr><th scope="col" class="text-focus py-3.5 ps-4 pe-3 text-start text-sm font-semibold sm:ps-6 lg:ps-8"><button type="button" class="flex items-center gap-2 whitespace-nowrap">${ssrInterpolate(_ctx.$t("Name"))} `);
			if (unref(filters)?.sort?.startsWith("name:")) _push(ssrRenderComponent(_component_Icon, {
				size: "size-3 text-mute",
				name: unref(filters).sort == "name:desc" ? "c-up" : "c-down"
			}, null, _parent));
			else _push(`<!---->`);
			_push(`</button></th><th scope="col" class="text-focus px-3 py-3.5 text-start text-sm font-semibold">${ssrInterpolate(_ctx.$t("Code"))}</th><th scope="col" class="text-focus px-3 py-3.5 text-start text-sm font-semibold">${ssrInterpolate(_ctx.$t("Description"))}</th><th scope="col" class="text-focus px-3 py-3.5 text-start text-sm font-semibold">${ssrInterpolate(_ctx.$t("Active"))}</th><th scope="col" class="relative w-16 py-3.5 ps-3 pe-4 sm:pe-6 lg:pe-8"><span class="sr-only">${ssrInterpolate(_ctx.$t("Actions"))}</span></th></tr></thead><tbody class="divide-y divide-gray-200 bg-white dark:divide-gray-700 dark:bg-gray-900">`);
			if (__props.pagination && __props.pagination.data && __props.pagination.data.length) {
				_push(`<!--[-->`);
				ssrRenderList(__props.pagination.data, (row) => {
					_push(`<tr><td class="text-focus py-4 ps-4 pe-3 text-sm font-medium whitespace-nowrap sm:ps-6 lg:ps-8">${ssrInterpolate(row.name)}</td><td class="px-3 py-4 text-sm whitespace-nowrap">${ssrInterpolate(row.code)}</td><td class="px-3 py-4 text-sm"><div class="line-clamp-2 max-w-xs min-w-56">${ssrInterpolate(row.description)}</div></td><td class="w-16 px-3 py-4 text-center text-sm whitespace-nowrap"><span class="-mb-1 inline-block size-5">${_ctx.$boolean(row.active) ?? ""}</span></td><td class="relative w-16 py-4 ps-3 pe-4 text-end text-sm font-medium whitespace-nowrap sm:pe-6 lg:pe-8">`);
					_push(ssrRenderComponent(unref(_sfc_main$5), {
						row,
						editRow,
						deleted: deleted.value,
						deleting: deleting.value,
						permission: "account-types",
						deleteRow,
						record: _ctx.$t("Account Type")
					}, null, _parent));
					_push(`</td></tr>`);
				});
				_push(`<!--]-->`);
			} else _push(`<tr><td colspan="100%"><div class="text-mute py-3.5 ps-4 pe-3 text-sm font-light whitespace-nowrap sm:ps-2 lg:ps-4">${ssrInterpolate(_ctx.$t("There is no data to display!"))}</div></td></tr>`);
			_push(`</tbody></table></div></div></div><div class="-mx-4 sm:-mx-6 lg:-mx-8">`);
			_push(ssrRenderComponent(unref(_sfc_main$6), {
				class: "mx-4 mt-auto py-2 text-sm sm:mx-6",
				meta: __props.pagination.meta,
				links: __props.pagination.links
			}, null, _parent));
			_push(`</div>`);
			_push(ssrRenderComponent(unref(_sfc_main$7), {
				show: add.value,
				backdrop: false,
				"max-width": "2xl",
				closeable: true,
				onClose: hideForm
			}, {
				default: withCtx((_, _push, _parent, _scopeId) => {
					if (_push) _push(ssrRenderComponent(_sfc_main$9, {
						current: current.value,
						onClose: hideForm,
						onDone: hideForm
					}, null, _parent, _scopeId));
					else return [createVNode(_sfc_main$9, {
						current: current.value,
						onClose: hideForm,
						onDone: hideForm
					}, null, 8, ["current"])];
				}),
				_: 1
			}, _parent));
			_push(`</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/Accounting/AccountType/Index.vue");
	return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
//#endregion
export { _sfc_main as default };
