import { a as require_react, o as __toESM, t as require_jsx_runtime } from "../index.js";
//#region app/service-catalog.ts
var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
var jt = 1e6;
var SERVICE_CATALOG = [
	{
		name: "Penyusunan AMDAL",
		category: "Lingkungan",
		duration: "6–12 bulan",
		feeLow: 350 * jt,
		feeHigh: 950 * jt,
		experts: "Ketua Tim/ATPA, ahli lingkungan, air, udara, biologi, sosial-ekonomi, GIS",
		legal: "UU 6/2023; PP 22/2021; Permen LHK 4/2021",
		stages: [
			"Penapisan kewajiban dan kewenangan",
			"Pengumuman serta konsultasi publik",
			"Penyusunan KA-ANDAL dan pelingkupan",
			"Survei rona awal dan penyusunan ANDAL",
			"Penyusunan RKL-RPL",
			"Uji kelayakan, perbaikan, dan SKKLH",
			"Integrasi Persetujuan Lingkungan ke OSS"
		]
	},
	{
		name: "Penyusunan Adendum AMDAL",
		category: "Lingkungan",
		duration: "4–9 bulan",
		feeLow: 250 * jt,
		feeHigh: 750 * jt,
		experts: "Ketua Tim/ATPA dan tenaga ahli sesuai komponen perubahan",
		legal: "UU 6/2023; PP 22/2021",
		stages: [
			"Audit perubahan rencana usaha",
			"Penapisan jenis perubahan dokumen",
			"Identifikasi data tambahan",
			"Penyusunan adendum ANDAL dan RKL-RPL",
			"Penilaian/uji kelayakan",
			"Perbaikan dan pembaruan persetujuan"
		]
	},
	{
		name: "Penyusunan UKL-UPL",
		category: "Lingkungan",
		duration: "2–4 bulan",
		feeLow: 85 * jt,
		feeHigh: 150 * jt,
		experts: "Ahli lingkungan, air/udara sesuai kegiatan, GIS",
		legal: "UU 6/2023; PP 22/2021; Permen LHK 4/2021",
		stages: [
			"Penapisan KBLI, skala, dan lokasi",
			"Pengumpulan data serta rona lingkungan",
			"Penyusunan matriks UKL-UPL",
			"Pengajuan melalui OSS/Amdalnet",
			"Pemeriksaan substansi dan perbaikan",
			"Penerbitan PKPLH"
		]
	},
	{
		name: "Penyusunan RKL-RPL Rinci",
		category: "Lingkungan",
		duration: "2–4 bulan",
		feeLow: 75 * jt,
		feeHigh: 150 * jt,
		experts: "Ahli lingkungan, teknis proses, GIS dan sosial",
		legal: "PP 22/2021 dan persetujuan lingkungan induk",
		stages: [
			"Telaah dokumen induk",
			"Pemetaan dampak dan penerima dampak",
			"Rencana pengelolaan rinci",
			"Rencana pemantauan, lokasi dan frekuensi",
			"Konsultasi instansi/pengelola kawasan",
			"Evaluasi dan finalisasi"
		]
	},
	{
		name: "Penyusunan PERTEK Air Limbah",
		category: "Persetujuan Teknis",
		duration: "3–6 bulan",
		feeLow: 90 * jt,
		feeHigh: 200 * jt,
		experts: "Ahli air limbah/proses, lingkungan, sipil dan laboratorium",
		legal: "PP 22/2021; Permen LHK 5/2021",
		stages: [
			"Penetapan baku mutu dan titik penaatan",
			"Survei serta karakterisasi air limbah",
			"Neraca air dan kajian teknis IPAL",
			"Penyusunan dokumen Persetujuan Teknis",
			"Evaluasi teknis dan perbaikan",
			"Penerbitan Pertek; dilanjutkan kesiapan SLO"
		]
	},
	{
		name: "Penyusunan PERTEK Emisi",
		category: "Persetujuan Teknis",
		duration: "3–6 bulan",
		feeLow: 75 * jt,
		feeHigh: 150 * jt,
		experts: "Ahli emisi/udara, proses, lingkungan dan laboratorium",
		legal: "PP 22/2021; Permen LHK 5/2021",
		stages: [
			"Inventarisasi sumber emisi",
			"Uji/sampling dan data bahan bakar",
			"Perhitungan beban serta dispersi bila perlu",
			"Desain pengendalian dan titik sampling",
			"Pengajuan, evaluasi, dan perbaikan",
			"Penerbitan Pertek; dilanjutkan kesiapan SLO"
		]
	},
	{
		name: "Penyusunan PERTEK Lainnya",
		category: "Persetujuan Teknis",
		duration: "3–6 bulan",
		feeLow: 75 * jt,
		feeHigh: 180 * jt,
		experts: "Ahli lingkungan dan ahli teknis sesuai jenis persetujuan",
		legal: "PP 22/2021 serta peraturan teknis sektoral",
		stages: [
			"Identifikasi kewajiban teknis",
			"Survei dan pengumpulan data",
			"Perhitungan/desain teknis",
			"Penyusunan dokumen",
			"Evaluasi instansi dan perbaikan",
			"Persetujuan dan integrasi dokumen lingkungan"
		]
	},
	{
		name: "Pengurusan SLO",
		category: "Persetujuan Teknis",
		duration: "2–5 bulan",
		feeLow: 50 * jt,
		feeHigh: 125 * jt,
		experts: "Ahli teknis sesuai Pertek, QA/QC, laboratorium terakreditasi",
		legal: "PP 22/2021; Permen LHK 5/2021",
		stages: [
			"Audit kesesuaian pembangunan terhadap Pertek",
			"Pengumpulan bukti commissioning",
			"Uji coba operasi dan hasil laboratorium",
			"Pengajuan permohonan SLO",
			"Verifikasi lapangan dan perbaikan",
			"Penerbitan SLO"
		]
	},
	{
		name: "Penyusunan Laporan Semester",
		category: "Pelaporan",
		duration: "4–8 minggu",
		feeLow: 35 * jt,
		feeHigh: 85 * jt,
		experts: "Ahli lingkungan, data analyst, laboratorium sesuai parameter",
		legal: "PP 22/2021 dan komitmen dalam Persetujuan Lingkungan",
		stages: [
			"Kompilasi data enam bulan",
			"Sampling/pengujian sesuai matriks",
			"Evaluasi terhadap baku mutu dan izin",
			"Analisis kepatuhan serta tindak lanjut",
			"Penyusunan dan QA laporan",
			"Penyampaian kepada instansi berwenang"
		]
	},
	{
		name: "Penyusunan Laporan Triwulan",
		category: "Pelaporan",
		duration: "3–6 minggu",
		feeLow: 25 * jt,
		feeHigh: 65 * jt,
		experts: "Ahli lingkungan, data analyst dan laboratorium",
		legal: "Persetujuan Lingkungan/Pertek dan ketentuan sektoral",
		stages: [
			"Kompilasi data triwulan",
			"Sampling bila diwajibkan",
			"Analisis kepatuhan",
			"Penyusunan matriks kinerja",
			"QA dan penyampaian laporan"
		]
	},
	{
		name: "Penyusunan Laporan Lainnya",
		category: "Pelaporan",
		duration: "2–8 minggu",
		feeLow: 20 * jt,
		feeHigh: 75 * jt,
		experts: "Tenaga ahli sesuai objek laporan",
		legal: "Mengikuti komitmen izin dan ketentuan sektoral terkait",
		stages: [
			"Konfirmasi format dan periode",
			"Pengumpulan bukti/data",
			"Analisis",
			"Penyusunan laporan",
			"QA, perbaikan, dan penyampaian"
		]
	},
	{
		name: "Penyusunan RINTEK PLB3",
		category: "Limbah B3",
		duration: "3–6 bulan",
		feeLow: 60 * jt,
		feeHigh: 125 * jt,
		experts: "Ahli PLB3, lingkungan, sipil/struktur dan K3",
		legal: "PP 22/2021; Permen LHK 6/2021",
		stages: [
			"Inventarisasi dan klasifikasi limbah B3",
			"Proyeksi timbulan dan kapasitas",
			"Pemilihan lokasi serta desain fasilitas",
			"SOP, tanggap darurat, dan neraca limbah",
			"Pengajuan dokumen rincian teknis",
			"Evaluasi, perbaikan, dan integrasi izin"
		]
	},
	{
		name: "Penyusunan ANDALALIN",
		category: "Transportasi",
		duration: "3–6 bulan",
		feeLow: 150 * jt,
		feeHigh: 300 * jt,
		experts: "Ketua tim dan ahli transportasi kompeten, surveyor, pemodel lalu lintas",
		legal: "Permenhub 17/2021 dan ketentuan lalu lintas yang berlaku",
		stages: [
			"Penetapan kategori bangkitan/tarikan",
			"Survei volume, kecepatan, dan geometrik",
			"Pemodelan kondisi eksisting dan proyeksi",
			"Rekayasa serta rekomendasi penanganan",
			"Pembahasan Tim Evaluasi",
			"Perbaikan dan persetujuan komitmen"
		]
	},
	{
		name: "Penyusunan PKKPR Darat",
		category: "Tata Ruang",
		duration: "2–5 bulan",
		feeLow: 100 * jt,
		feeHigh: 175 * jt,
		experts: "Ahli perencanaan wilayah/kota, GIS, pertanahan dan legal",
		legal: "UU 6/2023; PP 28/2025; panduan OSS RBA",
		stages: [
			"Validasi NIB, KBLI, dan risiko",
			"Penyusunan polygon serta data lokasi",
			"Pengajuan melalui OSS",
			"Verifikasi kesesuaian RTR",
			"Penilaian teknis dan pembayaran PNBP bila ada",
			"Perbaikan dan penerbitan PKKPR"
		]
	},
	{
		name: "Penyusunan PKKPR Laut",
		category: "Tata Ruang",
		duration: "3–8 bulan",
		feeLow: 175 * jt,
		feeHigh: 350 * jt,
		experts: "Ahli kelautan, tata ruang laut, hidrografi, GIS dan legal",
		legal: "UU 6/2023; PP 28/2025; ketentuan penataan ruang laut",
		stages: [
			"Validasi NIB/KBLI dan rencana pemanfaatan",
			"Penyusunan koordinat/polygon laut",
			"Data teknis, sosial dan pemanfaatan eksisting",
			"Pengajuan melalui OSS",
			"Penilaian teknis kesesuaian ruang laut",
			"PNBP, perbaikan, dan penerbitan PKKPRL"
		]
	},
	{
		name: "Kajian Business Plan",
		category: "Kajian",
		duration: "2–4 bulan",
		feeLow: 100 * jt,
		feeHigh: 300 * jt,
		experts: "Ahli bisnis, keuangan, pasar, legal dan teknis sektor",
		legal: "Standar profesi dan regulasi sektoral objek usaha",
		stages: [
			"Inception dan tujuan investasi",
			"Kajian pasar dan model bisnis",
			"Kajian teknis-operasional",
			"Model keuangan dan sensitivitas",
			"Analisis risiko serta mitigasi",
			"Final report dan presentasi"
		]
	},
	{
		name: "Kajian DED",
		category: "Kajian",
		duration: "3–8 bulan",
		feeLow: 150 * jt,
		feeHigh: 650 * jt,
		experts: "Team leader, sipil/struktur, proses, MEP, QS dan CAD/BIM",
		legal: "Standar teknis PUPR/SNI dan ketentuan sektoral terkait",
		stages: [
			"Survei dan pengumpulan data desain",
			"Kriteria dan konsep desain",
			"Perhitungan serta desain rinci",
			"Gambar, spesifikasi teknis, dan BoQ/RAB",
			"Review lintas disiplin dan QA/QC",
			"Finalisasi paket DED"
		]
	},
	{
		name: "Kajian Bathymetry",
		category: "Kajian",
		duration: "1–4 bulan",
		feeLow: 150 * jt,
		feeHigh: 500 * jt,
		experts: "Hidrografer, surveyor geodesi, oceanographer dan GIS",
		legal: "Standar survei hidrografi serta ketentuan keselamatan pelayaran",
		stages: [
			"Rencana survei dan perizinan lokasi",
			"Penetapan titik kontrol",
			"Mobilisasi serta kalibrasi alat",
			"Akuisisi sounding dan pasang surut",
			"Koreksi, pengolahan, dan QC data",
			"Peta batimetri dan laporan akhir"
		]
	},
	{
		name: "Kajian Lainnya",
		category: "Kajian",
		duration: "1–6 bulan",
		feeLow: 75 * jt,
		feeHigh: 300 * jt,
		experts: "Tenaga ahli multidisiplin sesuai kerangka acuan",
		legal: "Regulasi sektoral dan standar teknis sesuai objek kajian",
		stages: [
			"Penyusunan kerangka kerja",
			"Pengumpulan data primer/sekunder",
			"Analisis teknis",
			"Alternatif dan rekomendasi",
			"Konsultasi pemangku kepentingan",
			"Finalisasi laporan"
		]
	},
	{
		name: "Pengurusan Sertifikat Standar & UMKU",
		category: "Perizinan OSS",
		duration: "1–4 bulan",
		feeLow: 40 * jt,
		feeHigh: 150 * jt,
		experts: "Spesialis OSS/perizinan, legal dan tenaga teknis sektoral",
		legal: "UU 6/2023; PP 28/2025; NSPK sektoral di OSS",
		stages: [
			"Pemetaan KBLI, tingkat risiko, dan kewajiban",
			"Gap assessment persyaratan dasar",
			"Pemenuhan dokumen teknis/sektoral",
			"Pengajuan Sertifikat Standar atau PB UMKU",
			"Verifikasi, inspeksi bila diperlukan, dan perbaikan",
			"Penerbitan serta pemutakhiran data OSS"
		]
	},
	{
		name: "Pengurusan Sertifikat Usaha Lainnya",
		category: "Perizinan OSS",
		duration: "1–4 bulan",
		feeLow: 35 * jt,
		feeHigh: 125 * jt,
		experts: "Spesialis perizinan dan tenaga ahli sektor usaha",
		legal: "PP 28/2025 dan NSPK kementerian/lembaga pembina",
		stages: [
			"Identifikasi sertifikat dan kewenangan",
			"Checklist persyaratan",
			"Penyiapan dokumen",
			"Pengajuan dan pembayaran resmi bila ada",
			"Verifikasi/perbaikan",
			"Penerbitan dan arsip kepatuhan"
		]
	}
];
var SERVICE_NAMES = SERVICE_CATALOG.map((x) => x.name);
var COST_COMPONENTS = [
	["Tenaga ahli & personel", 55],
	["Survei dan pengumpulan data", 15],
	["Uji laboratorium/peralatan", 10],
	["Pembahasan, administrasi & dokumen", 8],
	["Perjalanan dan logistik", 7],
	["Kontinjensi lingkup", 5]
];
//#endregion
//#region app/document-builder.tsx
var import_jsx_runtime = require_jsx_runtime();
var rp$6 = (n) => new Intl.NumberFormat("id-ID", {
	style: "currency",
	currency: "IDR",
	maximumFractionDigits: 0
}).format(n || 0), today$4 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), fmt$5 = (d) => d ? new Intl.DateTimeFormat("id-ID", {
	day: "2-digit",
	month: "long",
	year: "numeric"
}).format(/* @__PURE__ */ new Date(d + "T00:00:00")) : "—";
function DocumentBuilder({ mode, clients, projects }) {
	const [docs, setDocs] = (0, import_react.useState)([]), [show, setShow] = (0, import_react.useState)(false), [selected, setSelected] = (0, import_react.useState)(null), [saving, setSaving] = (0, import_react.useState)(false), [message, setMessage] = (0, import_react.useState)(""), [items, setItems] = (0, import_react.useState)([{
		description: "Jasa konsultansi lingkungan",
		qty: 1,
		unit: "Paket",
		price: 0
	}]);
	const [serviceName, setServiceName] = (0, import_react.useState)(""), [feeLevel, setFeeLevel] = (0, import_react.useState)("recommended"), [sendDoc, setSendDoc] = (0, import_react.useState)(null), [receiptDoc, setReceiptDoc] = (0, import_react.useState)(null), [workflowDoc, setWorkflowDoc] = (0, import_react.useState)(null), [workflowStatus, setWorkflowStatus] = (0, import_react.useState)("Draft"), [sentAt, setSentAt] = (0, import_react.useState)(today$4), [sentTo, setSentTo] = (0, import_react.useState)(""), [paymentDate, setPaymentDate] = (0, import_react.useState)(today$4), [paymentMethod, setPaymentMethod] = (0, import_react.useState)("Transfer Bank");
	const [form, setForm] = (0, import_react.useState)({
		date: today$4,
		dueDate: "",
		clientId: "",
		projectId: "",
		subject: "",
		taxMode: "exclude",
		taxRate: "11",
		discountType: "percent",
		discountValue: "0",
		status: mode === "Penawaran" ? "Draft" : "Belum Terkirim",
		sentAt: "",
		sentTo: "",
		terms: "",
		notes: ""
	});
	const load = async () => {
		setDocs((await (await fetch("/api/documents", { cache: "no-store" })).json()).documents || []);
	};
	(0, import_react.useEffect)(() => {
		load();
		const open = () => setShow(true);
		window.addEventListener("open-document-builder", open);
		return () => window.removeEventListener("open-document-builder", open);
	}, []);
	const calc = (0, import_react.useMemo)(() => {
		const subtotal = items.reduce((a, x) => a + (Number(x.qty) || 0) * (Number(x.price) || 0), 0), dv = Number(form.discountValue) || 0, discount = form.discountType === "percent" ? subtotal * dv / 100 : Math.min(subtotal, dv), after = Math.max(0, subtotal - discount), rate = Number(form.taxRate) || 0, tax = form.taxMode === "exclude" ? after * rate / 100 : form.taxMode === "include" ? after * rate / (100 + rate) : 0;
		return {
			subtotal,
			discount,
			tax,
			total: form.taxMode === "exclude" ? after + tax : after
		};
	}, [items, form]);
	const change = (k, v) => setForm((x) => ({
		...x,
		[k]: v
	}));
	const applyTemplate = (name, level = "recommended") => {
		const s = SERVICE_CATALOG.find((x) => x.name === name);
		if (!s) return;
		const target = level === "low" ? s.feeLow : level === "high" ? s.feeHigh : (s.feeLow + s.feeHigh) / 2, round = (n) => Math.round(n / 5e5) * 5e5;
		setServiceName(name);
		setFeeLevel(level);
		setItems(COST_COMPONENTS.map(([label, pct]) => ({
			description: `${label} — ${s.name}`,
			qty: 1,
			unit: "Paket",
			price: round(target * pct / 100)
		})));
		setForm((x) => ({
			...x,
			subject: s.name,
			terms: "Pembayaran 30% setelah SPK, 40% setelah penyampaian draft, dan 30% setelah dokumen final/persetujuan sesuai ruang lingkup.",
			notes: `Durasi indikatif ${s.duration}. Acuan: ${s.legal}. Belum termasuk PPN, PNBP/retribusi resmi, pengujian khusus di luar lingkup, dan perjalanan di luar Batam.`
		}));
	};
	const chooseProject = (id) => {
		change("projectId", id);
		const p = projects.find((x) => x.id === Number(id));
		if (mode === "Penawaran" && p?.serviceType) applyTemplate(p.serviceType);
	};
	const save = async () => {
		setSaving(true);
		setMessage("");
		const r = await fetch("/api/documents", {
			method: "POST",
			headers: { "Content-Type": "application/json" },
			body: JSON.stringify({
				kind: "document",
				type: mode,
				...form,
				items
			})
		}), j = await r.json();
		setSaving(false);
		if (!r.ok) {
			setMessage(j.error || "Gagal menyimpan");
			return;
		}
		setMessage(`${mode} ${j.documentNo} berhasil disimpan.`);
		setShow(false);
		await load();
	};
	const markSent = async () => {
		if (!sendDoc || !sentTo) return;
		setSaving(true);
		const r = await fetch("/api/documents", {
			method: "POST",
			headers: { "Content-Type": "application/json" },
			body: JSON.stringify({
				kind: "update_status",
				id: sendDoc.id,
				status: "Terkirim",
				sentAt,
				sentTo
			})
		}), j = await r.json();
		setSaving(false);
		if (!r.ok) {
			setMessage(j.error || "Gagal memperbarui status");
			return;
		}
		setSendDoc(null);
		setSelected({
			...sendDoc,
			...j
		});
		setMessage(`Tagihan tercatat terkirim kepada ${sentTo}.`);
		await load();
	};
	const updateWorkflow = async () => {
		if (!workflowDoc) return;
		setSaving(true);
		const r = await fetch("/api/documents", {
			method: "POST",
			headers: { "Content-Type": "application/json" },
			body: JSON.stringify({
				kind: "update_status",
				id: workflowDoc.id,
				status: workflowStatus
			})
		}), j = await r.json();
		setSaving(false);
		if (!r.ok) {
			setMessage(j.error || "Gagal memperbarui status");
			return;
		}
		setWorkflowDoc(null);
		setSelected({
			...workflowDoc,
			...j
		});
		setMessage(`Tahapan penawaran diperbarui menjadi ${workflowStatus}.`);
		await load();
	};
	const makeReceipt = async () => {
		if (!receiptDoc) return;
		setSaving(true);
		const r = await fetch("/api/documents", {
			method: "POST",
			headers: { "Content-Type": "application/json" },
			body: JSON.stringify({
				kind: "receipt",
				sourceDocumentId: receiptDoc.id,
				paidAmount: receiptDoc.total,
				paymentDate,
				paymentMethod
			})
		}), j = await r.json();
		setSaving(false);
		if (!r.ok) {
			setMessage(j.error || "Gagal membuat kwitansi");
			return;
		}
		setReceiptDoc(null);
		await load();
		setSelected({
			...j,
			clientName: receiptDoc.clientName,
			clientAddress: receiptDoc.clientAddress,
			projectName: receiptDoc.projectName
		});
		setMessage(`Kwitansi ${j.documentNo} tercatat lunas.`);
	};
	const deleteDocument = async (doc) => {
		if (!window.confirm(`Hapus ${doc.type} ${doc.documentNo}? Rekap transaksi terkait juga akan disesuaikan.`)) return;
		setSaving(true);
		const r = await fetch(`/api/documents?id=${doc.id}`, { method: "DELETE" }), j = await r.json();
		setSaving(false);
		if (!r.ok) {
			setMessage(j.error || "Gagal menghapus dokumen");
			return;
		}
		if (selected?.id === doc.id) setSelected(null);
		setMessage(`${doc.type} ${doc.documentNo} berhasil dihapus.`);
		await load();
	};
	const list = docs.filter((d) => mode === "Penawaran" ? d.type === "Penawaran" : ["Tagihan", "Kwitansi"].includes(d.type));
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
		className: "document-workspace",
		children: [
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				className: "doc-hero",
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "COMMERCIAL DOCUMENT HUB" }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: mode === "Penawaran" ? "Buat Penawaran Profesional" : "Tagihan & Kwitansi Terintegrasi" }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Nomor dokumen tersusun otomatis dan seluruh status tersimpan dalam database." })
				] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
					className: "primary",
					onClick: () => setShow(true),
					children: ["＋ Buat ", mode]
				})]
			}),
			message && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				className: "doc-message",
				children: message
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				className: "doc-grid",
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", {
					className: "panel doc-list",
					children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
							className: "panel-head",
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h3", { children: ["Arsip ", mode] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [list.length, " dokumen tersimpan"] })] })
						}),
						list.map((d, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: `doc-archive-row ${selected?.id === d.id ? "selected" : ""}`,
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
								className: "doc-open",
								onClick: () => setSelected(d),
								children: [
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
										className: `doc-type ${d.type.toLowerCase()}`,
										children: String(i + 1).padStart(2, "0")
									}),
									/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: d.documentNo }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("small", { children: [
										d.clientName || "Klien",
										" • ",
										fmt$5(d.date)
									] })] }),
									/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: rp$6(d.total) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("em", { children: d.status })] })
								]
							}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
								className: "doc-delete",
								disabled: saving,
								onClick: () => deleteDocument(d),
								children: "Hapus"
							})]
						}, d.id)),
						!list.length && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
							className: "doc-empty",
							children: "Belum ada dokumen."
						})
					]
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("article", {
					className: "panel doc-preview",
					children: selected ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [mode === "Penawaran" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "workflow-toolbar",
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: ["Tahapan: ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: selected.status })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
							onClick: () => {
								setWorkflowDoc(selected);
								setWorkflowStatus(selected.status);
							},
							children: "↻ Ubah Tahapan"
						})]
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DocumentPrint, {
						doc: selected,
						saving,
						onReceipt: mode === "Tagihan" && selected.type === "Tagihan" ? () => {
							setReceiptDoc(selected);
							setPaymentDate(today$4);
						} : void 0,
						onSend: mode === "Tagihan" && selected.type === "Tagihan" && selected.status !== "Terkirim" ? () => {
							setSendDoc(selected);
							setSentAt(today$4);
							setSentTo(selected.clientName || "");
						} : void 0
					})] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "preview-empty",
						children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "▤" }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: "Pilih dokumen" }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Pratinjau siap cetak akan tampil di sini." })
						]
					})
				})]
			}),
			show && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				className: "modal-backdrop",
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "modal builder-modal",
					children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "modal-head",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "JLBB DOCUMENT COMPOSER" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: mode === "Penawaran" ? "Penawaran Harga" : "Tagihan / Invoice" })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
								onClick: () => setShow(false),
								children: "×"
							})]
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "builder-body",
							children: [
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
									className: "form-grid",
									children: [
										/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Nomor dokumen" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
											value: "Otomatis saat disimpan",
											disabled: true
										})] }),
										/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
											label: "Tanggal",
											type: "date",
											value: form.date,
											onChange: (v) => change("date", v)
										}),
										/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Klien *" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", {
											value: form.clientId,
											onChange: (e) => change("clientId", e.target.value),
											children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
												value: "",
												children: "— Pilih klien —"
											}), clients.map((c) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
												value: c.id,
												children: c.company
											}, c.id))]
										})] }),
										/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Proyek" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", {
											value: form.projectId,
											onChange: (e) => chooseProject(e.target.value),
											children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
												value: "",
												children: "— Umum —"
											}), projects.filter((p) => !form.clientId || p.clientId === Number(form.clientId)).map((p) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
												value: p.id,
												children: p.name
											}, p.id))]
										})] }),
										/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
											wide: true,
											label: "Perihal / pekerjaan",
											value: form.subject,
											onChange: (v) => change("subject", v)
										}),
										mode === "Penawaran" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Status Penawaran" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", {
											value: form.status,
											onChange: (e) => change("status", e.target.value),
											children: [
												/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { children: "Draft" }),
												/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { children: "Submit" }),
												/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { children: "Revisi" })
											]
										})] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
												label: "Jatuh tempo",
												type: "date",
												value: form.dueDate,
												onChange: (v) => change("dueDate", v)
											}),
											/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Status Pengiriman" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", {
												value: form.status,
												onChange: (e) => change("status", e.target.value),
												children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { children: "Belum Terkirim" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { children: "Terkirim" })]
											})] }),
											form.status === "Terkirim" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
												label: "Tanggal terkirim",
												type: "date",
												value: form.sentAt,
												onChange: (v) => change("sentAt", v)
											}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
												label: "Dikirim kepada",
												value: form.sentTo,
												onChange: (v) => change("sentTo", v)
											})] })
										] })
									]
								}),
								mode === "Penawaran" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
									className: "estimate-template",
									children: [
										/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
											className: "template-title",
											children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "TEMPLATE ESTIMASI BIAYA PROYEK" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: "Pilih jenis layanan untuk mengisi rincian otomatis" })] }), serviceName && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: SERVICE_CATALOG.find((x) => x.name === serviceName)?.duration })]
										}),
										/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
											className: "template-controls",
											children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Jenis proyek / layanan" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", {
												value: serviceName,
												onChange: (e) => applyTemplate(e.target.value),
												children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
													value: "",
													children: "— Pilih template layanan —"
												}), SERVICE_CATALOG.map((s) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("option", {
													value: s.name,
													children: [
														s.category,
														" — ",
														s.name
													]
												}, s.name))]
											})] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Skenario estimasi" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
												className: "fee-scenarios",
												children: [
													"low",
													"recommended",
													"high"
												].map((level) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
													disabled: !serviceName,
													className: feeLevel === level ? "active" : "",
													onClick: () => applyTemplate(serviceName, level),
													children: level === "low" ? "Minimum" : level === "high" ? "Maksimum" : "Rekomendasi"
												}, level))
											})] })]
										}),
										serviceName && (() => {
											const s = SERVICE_CATALOG.find((x) => x.name === serviceName);
											return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
												className: "template-summary",
												children: [
													/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "Rentang katalog" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("strong", { children: [
														rp$6(s.feeLow),
														" – ",
														rp$6(s.feeHigh)
													] })] }),
													/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "Nilai template" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: rp$6(calc.subtotal) })] }),
													/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "Tenaga ahli" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: s.experts })] })
												]
											});
										})()
									]
								}),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
									className: "items-title",
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: "Rincian Pekerjaan" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
										onClick: () => setItems((x) => [...x, {
											description: "",
											qty: 1,
											unit: "Paket",
											price: 0
										}]),
										children: "＋ Tambah baris"
									})]
								}),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
									className: "item-table",
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
										className: "item-head",
										children: [
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Deskripsi" }),
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Qty" }),
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Satuan" }),
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Harga" }),
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {})
										]
									}), items.map((it, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
										className: "item-row",
										children: [
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", {
												rows: 2,
												value: it.description,
												onChange: (e) => setItems((x) => x.map((v, j) => j === i ? {
													...v,
													description: e.target.value
												} : v))
											}),
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
												type: "number",
												value: it.qty,
												onChange: (e) => setItems((x) => x.map((v, j) => j === i ? {
													...v,
													qty: Number(e.target.value)
												} : v))
											}),
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
												value: it.unit,
												onChange: (e) => setItems((x) => x.map((v, j) => j === i ? {
													...v,
													unit: e.target.value
												} : v))
											}),
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
												type: "number",
												value: it.price,
												onChange: (e) => setItems((x) => x.map((v, j) => j === i ? {
													...v,
													price: Number(e.target.value)
												} : v))
											}),
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
												disabled: items.length === 1,
												onClick: () => setItems((x) => x.filter((_, j) => j !== i)),
												children: "×"
											})
										]
									}, i))]
								}),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
									className: "calc-area",
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
										className: "tax-options",
										children: [
											/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Perlakuan Pajak" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", {
												value: form.taxMode,
												onChange: (e) => change("taxMode", e.target.value),
												children: [
													/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
														value: "exclude",
														children: "Exclude Tax"
													}),
													/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
														value: "include",
														children: "Include Tax"
													}),
													/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
														value: "none",
														children: "Non-Pajak"
													})
												]
											})] }),
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
												label: "Tarif pajak (%)",
												type: "number",
												value: form.taxRate,
												onChange: (v) => change("taxRate", v)
											}),
											/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Jenis diskon" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", {
												value: form.discountType,
												onChange: (e) => change("discountType", e.target.value),
												children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
													value: "percent",
													children: "Persentase (%)"
												}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
													value: "nominal",
													children: "Nominal (Rp)"
												})]
											})] }),
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
												label: "Nilai diskon",
												type: "number",
												value: form.discountValue,
												onChange: (v) => change("discountValue", v)
											})
										]
									}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
										className: "live-total",
										children: [
											/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Subtotal" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: rp$6(calc.subtotal) })] }),
											/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Diskon" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("b", { children: ["- ", rp$6(calc.discount)] })] }),
											/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Pajak" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: rp$6(calc.tax) })] }),
											/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
												className: "grand",
												children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "TOTAL" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: rp$6(calc.total) })]
											})
										]
									})]
								}),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
									className: "form-grid notes",
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
										wide: true,
										multiline: true,
										label: "Syarat pembayaran",
										value: form.terms,
										onChange: (v) => change("terms", v)
									}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
										wide: true,
										multiline: true,
										label: "Catatan",
										value: form.notes,
										onChange: (v) => change("notes", v)
									})]
								})
							]
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "modal-actions",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
								onClick: () => setShow(false),
								children: "Batal"
							}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
								className: "primary",
								disabled: saving,
								onClick: save,
								children: saving ? "Menyimpan…" : `Simpan ${mode}`
							})]
						})
					]
				})
			}),
			sendDoc && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				className: "modal-backdrop",
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "modal action-modal",
					children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "modal-head",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "STATUS PENGIRIMAN" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: "Catat Tagihan Terkirim" })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
								onClick: () => setSendDoc(null),
								children: "×"
							})]
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "form-grid",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
								label: "Tanggal terkirim",
								type: "date",
								value: sentAt,
								onChange: setSentAt
							}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
								label: "Dikirim kepada",
								value: sentTo,
								onChange: setSentTo
							})]
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "modal-actions",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
								onClick: () => setSendDoc(null),
								children: "Batal"
							}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
								className: "primary",
								disabled: saving || !sentTo,
								onClick: markSent,
								children: "Simpan Status"
							})]
						})
					]
				})
			}),
			receiptDoc && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				className: "modal-backdrop",
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "modal action-modal",
					children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "modal-head",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "KONFIRMASI PEMBAYARAN" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: "Buat Receipt / Kwitansi" })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
								onClick: () => setReceiptDoc(null),
								children: "×"
							})]
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "form-grid",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
								label: "Tanggal dibayar",
								type: "date",
								value: paymentDate,
								onChange: setPaymentDate
							}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Cara pembayaran" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", {
								value: paymentMethod,
								onChange: (e) => setPaymentMethod(e.target.value),
								children: [
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { children: "Transfer Bank" }),
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { children: "Tunai" }),
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { children: "Giro" }),
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { children: "Cek" }),
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { children: "Virtual Account" }),
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { children: "Lainnya" })
								]
							})] })]
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "payment-confirm",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Jumlah pembayaran" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: rp$6(receiptDoc.total) })]
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "modal-actions",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
								onClick: () => setReceiptDoc(null),
								children: "Batal"
							}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
								className: "primary",
								disabled: saving,
								onClick: makeReceipt,
								children: "Terbitkan Kwitansi"
							})]
						})
					]
				})
			}),
			workflowDoc && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				className: "modal-backdrop",
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "modal action-modal",
					children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "modal-head",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "TAHAPAN PENAWARAN" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: "Ubah Status Dokumen" })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
								onClick: () => setWorkflowDoc(null),
								children: "×"
							})]
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
							className: "form-grid",
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
								className: "wide",
								children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Tahapan saat ini" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", {
									value: workflowStatus,
									onChange: (e) => setWorkflowStatus(e.target.value),
									children: [
										/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { children: "Draft" }),
										/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { children: "Revisi" }),
										/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { children: "Disetujui" })
									]
								})]
							})
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "workflow-line",
							children: [
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", {
									className: workflowStatus !== "Draft" ? "done" : "active",
									children: "1"
								}),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Draft" }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", {
									className: workflowStatus === "Disetujui" ? "done" : workflowStatus === "Revisi" ? "active" : "",
									children: "2"
								}),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Revisi" }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", {
									className: workflowStatus === "Disetujui" ? "active" : "",
									children: "3"
								}),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Disetujui" })
							]
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "modal-actions",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
								onClick: () => setWorkflowDoc(null),
								children: "Batal"
							}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
								className: "primary",
								disabled: saving,
								onClick: updateWorkflow,
								children: "Simpan Tahapan"
							})]
						})
					]
				})
			})
		]
	});
}
function DocumentPrint({ doc, onReceipt, onSend, saving }) {
	const items = JSON.parse(doc.itemsJson || "[]");
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
		className: "print-doc",
		children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
			className: "doc-toolbar",
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: ["Pratinjau ", doc.type] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
				onSend && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
					onClick: onSend,
					children: "✉ Tandai Terkirim"
				}),
				onReceipt && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
					onClick: onReceipt,
					disabled: saving,
					children: "✓ Catat Pembayaran & Kwitansi"
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
					onClick: () => window.print(),
					children: "⇩ Cetak / PDF"
				})
			] })]
		}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
			className: "doc-paper standard-finance-doc",
			children: [
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "doc-letterhead",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", {
						src: "/logo.png",
						alt: "JLBB"
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: "PT. JASA LINGKUNGAN BAHARI BATAM" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Komplek Ruko Golden City Blok RI 17, Batam, Kepulauan Riau" })] })]
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "doc-title",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { children: doc.type.toUpperCase() }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: doc.documentNo })]
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "doc-parties",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "Kepada Yth." }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: doc.clientName }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: doc.clientAddress || "Alamat klien belum diisi" })
					] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Tanggal" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: fmt$5(doc.date) })] }),
						doc.dueDate && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Jatuh tempo" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: fmt$5(doc.dueDate) })] }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Status" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: doc.status })] }),
						doc.sentAt && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Terkirim" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("b", { children: [
							fmt$5(doc.sentAt),
							" · ",
							doc.sentTo
						] })] }),
						doc.paymentDate && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Dibayar" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("b", { children: [
							fmt$5(doc.paymentDate),
							" · ",
							doc.paymentMethod
						] })] })
					] })]
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h3", {
					className: "doc-subject",
					children: ["Perihal: ", doc.subject]
				}),
				doc.type === "Kwitansi" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "receipt-box",
					children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "SUDAH TERIMA DARI" }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: doc.clientName }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "UANG SEJUMLAH" }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", {
							className: "amount",
							children: rp$6(doc.total)
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: ["Untuk pembayaran: ", doc.subject] }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: "Tanggal pembayaran:" }),
							" ",
							fmt$5(doc.paymentDate),
							" · ",
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: "Metode:" }),
							" ",
							doc.paymentMethod
						] })
					]
				}) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("table", {
					className: "doc-items",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "No." }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Uraian" }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Qty" }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Harga Satuan" }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Jumlah" })
					] }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { children: items.map((x, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: i + 1 }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("td", { children: [x.description, /* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: x.unit })] }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: x.qty }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: rp$6(x.price) }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: rp$6(x.qty * x.price) })
					] }, i)) })]
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "doc-totals",
					children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Subtotal" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: rp$6(doc.subtotal) })] }),
						doc.discountAmount > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Diskon" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("b", { children: ["- ", rp$6(doc.discountAmount)] })] }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: ["Pajak ", doc.taxMode === "include" ? "(include)" : doc.taxMode === "exclude" ? `${doc.taxRate}% (exclude)` : "(non-pajak)"] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: rp$6(doc.taxAmount) })] }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "TOTAL" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: rp$6(doc.total) })] })
					]
				}),
				doc.terms && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "doc-terms",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "Syarat Pembayaran" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: doc.terms })]
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "doc-sign",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Hormat kami," }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "PT. Jasa Lingkungan Bahari Batam" })
					] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: ["Batam, ", fmt$5(doc.date)] }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "Andika Pratama, ST" }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "Direktur" })
					] })]
				})
			]
		})]
	});
}
function Field$1({ label, value, onChange, type = "text", wide = false, multiline = false }) {
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
		className: wide ? "wide" : "",
		children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: label }), multiline ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", {
			rows: 3,
			value,
			onChange: (e) => onChange(e.target.value)
		}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
			type,
			value,
			onChange: (e) => onChange(e.target.value)
		})]
	});
}
//#endregion
//#region app/finance-dashboard.tsx
var today$3 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), monthStart = today$3.slice(0, 8) + "01", rp$5 = (n) => new Intl.NumberFormat("id-ID", {
	style: "currency",
	currency: "IDR",
	maximumFractionDigits: 0
}).format(n || 0), short = (n) => n >= 1e9 ? `Rp ${(n / 1e9).toFixed(1)} M` : n >= 1e6 ? `Rp ${(n / 1e6).toFixed(0)} jt` : rp$5(n), fmt$4 = (d) => new Intl.DateTimeFormat("id-ID", {
	day: "2-digit",
	month: "short",
	year: "numeric"
}).format(/* @__PURE__ */ new Date(d + "T00:00:00"));
function FinanceDashboard({ data, alerts, go }) {
	const [from, setFrom] = (0, import_react.useState)(monthStart), [to, setTo] = (0, import_react.useState)(today$3), rows = (0, import_react.useMemo)(() => data.entries.filter((e) => e.date >= from && e.date <= to), [
		data.entries,
		from,
		to
	]), income = rows.filter((e) => e.direction === "Masuk" && e.category !== "Penawaran").reduce((a, e) => a + e.paidAmount, 0), expense = rows.filter((e) => e.direction === "Keluar").reduce((a, e) => a + e.paidAmount, 0), receivable = rows.filter((e) => e.direction === "Masuk" && ["Invoice", "Piutang"].includes(e.category)).reduce((a, e) => a + Math.max(0, e.amount - e.paidAmount), 0), payable = rows.filter((e) => e.direction === "Keluar" && ["Hutang", "Tagihan"].includes(e.category)).reduce((a, e) => a + Math.max(0, e.amount - e.paidAmount), 0), profit = income - expense, contract = data.projects.reduce((a, p) => a + p.contractValue, 0), assetValue = data.assets.reduce((a, x) => a + x.acquisitionValue, 0), cash = income - expense, totalAssets = cash + receivable + assetValue, equity = totalAssets - payable, balanceMax = Math.max(1, Math.abs(totalAssets), Math.abs(payable), Math.abs(equity)), recent = rows.slice(0, 7), total = Math.max(1, income + expense), incomeDeg = Math.round(income / total * 360);
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
		className: "executive-dashboard",
		children: [
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
				className: "executive-intro",
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "EXECUTIVE FINANCE OVERVIEW" }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: "Ringkasan keuangan berdasarkan periode." }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Seluruh angka dihitung dari transaksi database pada tanggal yang dipilih." })
				] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "dashboard-range",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: ["Dari", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
						type: "date",
						value: from,
						onChange: (e) => setFrom(e.target.value)
					})] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: ["Sampai", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
						type: "date",
						value: to,
						onChange: (e) => setTo(e.target.value)
					})] })]
				})]
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
				className: "metric-cards",
				children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Metric, {
						tone: "cyan",
						label: "Total Penerimaan",
						value: rp$5(income),
						note: "Kas masuk terealisasi"
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Metric, {
						tone: "violet",
						label: "Total Pengeluaran",
						value: rp$5(expense),
						note: "Biaya proyek & operasi"
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Metric, {
						tone: "blue",
						label: "Laba / Rugi",
						value: rp$5(profit),
						note: profit >= 0 ? "Posisi surplus" : "Posisi defisit"
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Metric, {
						tone: "amber",
						label: "Nilai Kontrak",
						value: rp$5(contract),
						note: `${data.projects.filter((p) => p.status === "Berjalan").length} proyek berjalan`
					})
				]
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
				className: "analytics-grid",
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", {
					className: "analytics-card",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
						className: "analytics-head",
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: "Komposisi Kas" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
							fmt$4(from),
							" — ",
							fmt$4(to)
						] })] })
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "donut-wrap",
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
							className: "donut",
							style: { background: `conic-gradient(#12a9cf 0deg ${incomeDeg}deg,#786fe8 ${incomeDeg}deg 360deg)` },
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("strong", { children: [Math.round(income / total * 100), "%"] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "Kas masuk" })] })
						}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "donut-data",
							children: [
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { className: "cash-in" }),
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Penerimaan" }),
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: short(income) })
								] }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { className: "cash-out" }),
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Pengeluaran" }),
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: short(expense) })
								] }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
									className: "net",
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Saldo bersih" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", {
										className: profit >= 0 ? "up" : "down",
										children: short(profit)
									})]
								})
							]
						})]
					})]
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", {
					className: "analytics-card balance-balloon",
					children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "analytics-head",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: "Ringkasan Neraca" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Aktiva = kewajiban + ekuitas" })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
								onClick: () => go("balance"),
								children: "Buka Neraca →"
							})]
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "balance-visual",
							children: [
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Total Aktiva" }),
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { style: { width: `${Math.abs(totalAssets) / balanceMax * 100}%` } }) }),
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: short(totalAssets) })
								] }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Hutang" }),
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { style: { width: `${Math.abs(payable) / balanceMax * 100}%` } }) }),
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: short(payable) })
								] }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Ekuitas" }),
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { style: { width: `${Math.abs(equity) / balanceMax * 100}%` } }) }),
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: short(equity) })
								] })
							]
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("footer", { children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: ["Kas ", short(cash)] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: ["Piutang ", short(receivable)] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: ["Aset ", short(assetValue)] })
						] })
					]
				})]
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
				className: "overview-grid",
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", {
					className: "analytics-card recent-card",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "analytics-head",
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: "Transaksi Periode" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Tampilan ringkas tanggal, jenis, dan jumlah" })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
							onClick: () => go("transactions"),
							children: "Lihat semua →"
						})]
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
						className: "dashboard-table compact",
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("table", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Tanggal" }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Jenis transaksi" }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Jumlah" })
						] }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tbody", { children: [recent.map((e) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: fmt$4(e.date) }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("td", { children: [
								e.category,
								" — ",
								e.description
							] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
								className: "value",
								children: rp$5(e.paidAmount || e.amount)
							})
						] }, e.id)), !recent.length && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
							colSpan: 3,
							children: "Tidak ada transaksi pada periode ini."
						}) })] })] })
					})]
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("aside", {
					className: "overview-side",
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", {
						className: "analytics-card deadlines",
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "analytics-head",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: "Jatuh Tempo" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Perlu ditindaklanjuti" })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
								onClick: () => go("notifications"),
								children: "Detail"
							})]
						}), alerts.slice(0, 5).map((a) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "deadline-row",
							children: [
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
									className: a.days < 0 ? "late" : "",
									children: a.days < 0 ? "!" : a.days
								}),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: a.description }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: fmt$4(a.dueDate) })] }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: short(a.amount - a.paidAmount) })
							]
						}, a.id))]
					})
				})]
			})
		]
	});
}
function Metric({ tone, label, value, note }) {
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", {
		className: `metric-card ${tone}`,
		children: [
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "●" }),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: label }),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: value }),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: note })
			] }),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)("em", { children: "•••" })
		]
	});
}
//#endregion
//#region app/project-services.tsx
var rp$4 = (n) => new Intl.NumberFormat("id-ID", {
	style: "currency",
	currency: "IDR",
	maximumFractionDigits: 0
}).format(n || 0);
var shortRp = (n) => n >= 1e9 ? `Rp ${(n / 1e9).toFixed(1)} M` : n >= 1e6 ? `Rp ${(n / 1e6).toFixed(0)} jt` : rp$4(n);
var fmt$3 = (d) => d ? new Intl.DateTimeFormat("id-ID", {
	day: "2-digit",
	month: "short",
	year: "numeric"
}).format(/* @__PURE__ */ new Date(d + "T00:00:00")) : "—";
function ProjectServices({ projects, entries, onDelete, onEdit }) {
	const [view, setView] = (0, import_react.useState)("catalog"), [category, setCategory] = (0, import_react.useState)("Semua"), [query, setQuery] = (0, import_react.useState)(""), [selected, setSelected] = (0, import_react.useState)(0);
	const [editing, setEditing] = (0, import_react.useState)(null), [saving, setSaving] = (0, import_react.useState)(false), [editError, setEditError] = (0, import_react.useState)("");
	const categories = ["Semua", ...Array.from(new Set(SERVICE_CATALOG.map((x) => x.category)))];
	const filtered = (0, import_react.useMemo)(() => SERVICE_CATALOG.filter((x) => (category === "Semua" || x.category === category) && x.name.toLowerCase().includes(query.toLowerCase())), [category, query]);
	const service = SERVICE_CATALOG[selected];
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
		className: "project-services",
		children: [
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				className: "project-hero",
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "KATALOG PROYEK TERINTEGRASI" }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: "Layanan, tahapan, dan kendali biaya proyek" }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Pilih layanan untuk melihat alur pengurusan, tim ahli, durasi, dan rentang estimasi fee." })
				] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: SERVICE_CATALOG.length }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "jenis layanan" })] })]
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				className: "project-tabs",
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
					className: view === "catalog" ? "active" : "",
					onClick: () => setView("catalog"),
					children: "Katalog Layanan & Biaya"
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
					className: view === "active" ? "active" : "",
					onClick: () => setView("active"),
					children: ["Status Proyek ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: projects.length })]
				})]
			}),
			view === "active" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				className: "project-groups",
				children: [
					["Sedang Berjalan", projects.filter((p) => p.status === "Berjalan" || p.status === "Perencanaan" || p.status === "Tertunda")],
					["Selesai", projects.filter((p) => p.status === "Selesai" || p.progress >= 100)],
					["Berhenti / Tidak Dilanjutkan", projects.filter((p) => /berhenti|tidak dilanjutkan/i.test(p.status))]
				].map(([label, list]) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "group-heading",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: label }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [list.length, " proyek"] })]
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "cards-grid",
					children: [list.map((p, i) => {
						const inc = entries.filter((e) => e.projectId === p.id && e.direction === "Masuk").reduce((a, e) => a + e.paidAmount, 0), out = entries.filter((e) => e.projectId === p.id && e.direction === "Keluar").reduce((a, e) => a + e.paidAmount, 0), paid = p.contractValue > 0 && inc >= p.contractValue;
						return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", {
							className: "project-card",
							children: [
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
									className: "project-top",
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
										String(i + 1).padStart(2, "0"),
										" · ",
										p.code
									] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("em", { children: p.status })]
								}),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: p.name }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
									p.serviceType || "Layanan belum dipilih",
									" · ",
									p.clientName || "Tanpa klien"
								] }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
									className: "payment-state",
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", {
										className: paid ? "paid" : "unpaid",
										children: paid ? "Sudah Terbayar" : "Belum Terbayar"
									}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
										shortRp(inc),
										" / ",
										shortRp(p.contractValue)
									] })]
								}),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
									className: "metric-row",
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "Nilai kontrak" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: shortRp(p.contractValue) })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "Laba kas" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", {
										className: inc - out >= 0 ? "positive" : "negative",
										children: shortRp(inc - out)
									})] })]
								}),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
									className: "progress",
									children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { style: { width: `${p.progress}%` } })
								}),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
									className: "project-foot",
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
										"Progres ",
										p.progress,
										"%"
									] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: ["Target ", fmt$3(p.endDate)] })]
								}),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
									className: "project-actions",
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
										className: "edit-project",
										onClick: () => {
											setEditing(p);
											setEditError("");
										},
										children: "Edit Proyek"
									}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
										className: "delete-project",
										onClick: () => onDelete("project", p.id, p.name),
										children: "Hapus Proyek"
									})]
								})
							]
						}, p.id);
					}), !list.length && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
						className: "catalog-empty",
						children: "Tidak ada proyek pada kelompok ini."
					})]
				})] }, label))
			}) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "catalog-tools",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
						className: "category-chips",
						children: categories.map((c) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
							className: category === c ? "active" : "",
							onClick: () => setCategory(c),
							children: c
						}, c))
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
						value: query,
						onChange: (e) => setQuery(e.target.value),
						placeholder: "Cari AMDAL, Pertek, PKKPR…"
					})]
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "catalog-layout",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "service-list",
						children: [filtered.map((item) => {
							const idx = SERVICE_CATALOG.indexOf(item);
							return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
								className: selected === idx ? "selected" : "",
								onClick: () => setSelected(idx),
								children: [
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: item.category }),
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: item.name }),
									/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("small", { children: [
										item.duration,
										" · ",
										shortRp(item.feeLow),
										"–",
										shortRp(item.feeHigh)
									] })
								]
							}, item.name);
						}), !filtered.length && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
							className: "catalog-empty",
							children: "Layanan tidak ditemukan."
						})]
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", {
						className: "service-detail",
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "service-detail-head",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: service.category }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: service.name }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: service.legal })
							] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "Estimasi fee jasa" }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("strong", { children: [
									shortRp(service.feeLow),
									"–",
									shortRp(service.feeHigh)
								] }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("em", { children: service.duration })
							] })]
						}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "service-grid",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", { children: "Tahapan pekerjaan & pengurusan" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ol", { children: service.stages.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: i + 1 }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: s })] }, s)) })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", { children: "Komposisi tenaga ahli" }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
									className: "expert-box",
									children: service.experts
								}),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", { children: "Simulasi komponen biaya" }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
									className: "cost-bars",
									children: COST_COMPONENTS.map(([label, pct]) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
										/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [label, /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("b", { children: [pct, "%"] })] }),
										/* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("em", { style: { width: `${pct}%` } }) }),
										/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("small", { children: [
											rp$4(service.feeLow * pct / 100),
											"–",
											rp$4(service.feeHigh * pct / 100)
										] })
									] }, label))
								})
							] })]
						})]
					})]
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "estimate-note",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "Catatan estimasi." }), " Rentang di atas adalah anggaran awal jasa konsultansi JLBB berbasis kompleksitas, kebutuhan personel, remunerasi minimal tenaga ahli Kementerian PU, dan Billing Rate INKINDO. Nilai final wajib mengikuti KAK, lokasi, volume survei, jenjang/masa kerja ahli, dan negosiasi. Belum termasuk PPN, PNBP/retribusi resmi, sampling/laboratorium khusus, perjalanan luar Batam, pengadaan alat, dan pekerjaan konstruksi kecuali dinyatakan dalam penawaran."]
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "regulation-links",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: "Dasar acuan utama" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
							href: "https://peraturan.bpk.go.id/Details/246523/uu-no-6-tahun-2023",
							target: "_blank",
							rel: "noreferrer",
							children: "UU 6/2023 Cipta Kerja"
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
							href: "https://peraturan.bpk.go.id/Details/319773/pp-no-28-tahun-2025",
							target: "_blank",
							rel: "noreferrer",
							children: "PP 28/2025 OSS-RBA"
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
							href: "https://peraturan.go.id/id/pp-no-22-tahun-2021",
							target: "_blank",
							rel: "noreferrer",
							children: "PP 22/2021 PPLH"
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
							href: "https://jdih.pu.go.id/detail-dokumen/KepmenPU-nomor-33KPTSMM2025-tahun-2025-BESARAN-REMUNERASI-MINIMAL-TENAGA-KERJA-KONSTRUKSI-PADA-JENJANG-KUALIFIKASI-AHLI-UNTUK-LAYANAN-JASA-KONSULTANSI-KONSTRUKSI",
							target: "_blank",
							rel: "noreferrer",
							children: "Kepmen PU 33/KPTS/M/2025"
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
							href: "https://www.inkindo.org/news/buku-billing-rate-inkindo-2026",
							target: "_blank",
							rel: "noreferrer",
							children: "Billing Rate INKINDO 2026"
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
							href: "https://oss.go.id/id/panduan",
							target: "_blank",
							rel: "noreferrer",
							children: "Panduan OSS"
						})
					] })]
				})
			] }),
			editing && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				className: "modal-backdrop",
				onMouseDown: (e) => e.target === e.currentTarget && setEditing(null),
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", {
					className: "modal project-edit-modal",
					onSubmit: async (e) => {
						e.preventDefault();
						setSaving(true);
						setEditError("");
						const ok = await onEdit(editing.id, Object.fromEntries(new FormData(e.currentTarget).entries()));
						setSaving(false);
						if (ok) setEditing(null);
						else setEditError("Perubahan belum dapat disimpan.");
					},
					children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "modal-head",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "PERBARUI DATA PROYEK" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: editing.code })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
								type: "button",
								onClick: () => setEditing(null),
								children: "×"
							})]
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "form-grid",
							children: [
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
									className: "wide",
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Nama proyek" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
										name: "name",
										defaultValue: editing.name,
										required: true
									})]
								}),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
									className: "wide",
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Jenis layanan" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", {
										name: "serviceType",
										defaultValue: editing.serviceType || "",
										children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
											value: "",
											children: "— Pilih layanan —"
										}), SERVICE_CATALOG.map((s) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { children: s.name }, s.name))]
									})]
								}),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Nilai kontrak" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
									name: "contractValue",
									type: "number",
									defaultValue: editing.contractValue
								})] }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Anggaran biaya" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
									name: "budget",
									type: "number",
									defaultValue: editing.budget
								})] }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Progres (%)" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
									name: "progress",
									type: "number",
									min: "0",
									max: "100",
									defaultValue: editing.progress
								})] }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Status" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", {
									name: "status",
									defaultValue: editing.status,
									children: [
										"Perencanaan",
										"Berjalan",
										"Tertunda",
										"Selesai",
										"Berhenti / Tidak Dilanjutkan"
									].map((s) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { children: s }, s))
								})] }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Tanggal mulai" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
									name: "startDate",
									type: "date",
									defaultValue: editing.startDate
								})] }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Target selesai" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
									name: "endDate",
									type: "date",
									defaultValue: editing.endDate
								})] })
							]
						}),
						editError && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
							className: "form-error",
							children: editError
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "modal-actions",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
								type: "button",
								onClick: () => setEditing(null),
								children: "Batal"
							}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
								className: "primary",
								disabled: saving,
								children: saving ? "Menyimpan…" : "Simpan Perubahan"
							})]
						})
					]
				})
			})
		]
	});
}
//#endregion
//#region app/balance-sheet.tsx
var today$2 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), rp$3 = (n) => new Intl.NumberFormat("id-ID", {
	style: "currency",
	currency: "IDR",
	maximumFractionDigits: 0
}).format(n || 0), monthName = (m) => new Intl.DateTimeFormat("id-ID", {
	month: "long",
	year: "numeric"
}).format(/* @__PURE__ */ new Date(`${m}-01T00:00:00`)), fmt$2 = (d) => d ? new Intl.DateTimeFormat("id-ID", {
	day: "2-digit",
	month: "short",
	year: "numeric"
}).format(/* @__PURE__ */ new Date(d + "T00:00:00")) : "—";
function BalanceSheet({ entries, assets, approvals, role, onApprove, onStatus, onAdd }) {
	const [month, setMonth] = (0, import_react.useState)(today$2.slice(0, 7)), [view, setView] = (0, import_react.useState)("summary");
	const data = (0, import_react.useMemo)(() => {
		const end = `${month}-31`, monthly = entries.filter((e) => e.date.startsWith(month)), cumulative = entries.filter((e) => e.date <= end), cash = cumulative.filter((e) => e.direction === "Masuk" && e.category !== "Penawaran").reduce((a, e) => a + e.paidAmount, 0) - cumulative.filter((e) => e.direction === "Keluar").reduce((a, e) => a + e.paidAmount, 0), receivableRows = cumulative.filter((e) => e.direction === "Masuk" && ["Invoice", "Piutang"].includes(e.category)), payableRows = cumulative.filter((e) => e.direction === "Keluar" && ["Hutang", "Tagihan"].includes(e.category)), receivable = receivableRows.reduce((a, e) => a + Math.max(0, e.amount - e.paidAmount), 0), payable = payableRows.reduce((a, e) => a + Math.max(0, e.amount - e.paidAmount), 0), assetRows = assets.filter((a) => !a.acquisitionDate || a.acquisitionDate <= end), bookValue = (a) => {
			if (!a.acquisitionDate || !a.usefulLife) return a.acquisitionValue;
			const acquired = /* @__PURE__ */ new Date(`${a.acquisitionDate}T00:00:00`), asOf = /* @__PURE__ */ new Date(`${month}-28T00:00:00`), months = Math.max(0, (asOf.getFullYear() - acquired.getFullYear()) * 12 + asOf.getMonth() - acquired.getMonth());
			return Math.max(0, a.acquisitionValue * (1 - months / (a.usefulLife * 12)));
		}, fixedAssets = assetRows.reduce((s, a) => s + bookValue(a), 0), revenue = monthly.filter((e) => e.direction === "Masuk" && e.category !== "Penawaran").reduce((a, e) => a + e.paidAmount, 0), expense = monthly.filter((e) => e.direction === "Keluar").reduce((a, e) => a + e.paidAmount, 0), totalAssets = cash + receivable + fixedAssets, equity = totalAssets - payable;
		return {
			monthly,
			cash,
			receivableRows,
			payableRows,
			receivable,
			payable,
			assetRows,
			bookValue,
			fixedAssets,
			revenue,
			expense,
			profit: revenue - expense,
			totalAssets,
			equity
		};
	}, [
		entries,
		assets,
		month
	]);
	const approval = approvals.find((a) => a.reportType === "Neraca" && a.period === month);
	const DebtTable = ({ rows }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
		className: "table-wrap",
		children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("table", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Tanggal" }),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Jenis & Uraian" }),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Relasi" }),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Nilai" }),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Terbayar" }),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Sisa" }),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Tahapan" })
		] }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tbody", { children: [rows.map((e) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: fmt$2(e.date) }),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("td", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: e.category }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: e.description })] }),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: e.clientName || e.projectName || "Umum" }),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: rp$3(e.amount) }),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: rp$3(e.paidAmount) }),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: rp$3(Math.max(0, e.amount - e.paidAmount)) }),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("td", { children: [role === "manager" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", {
				className: "status-select no-print",
				value: [
					"Draft",
					"Revisi",
					"Telah Dibayarkan"
				].includes(e.status) ? e.status : "Draft",
				onChange: (x) => onStatus(e, x.target.value),
				children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { children: "Draft" }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { children: "Revisi" }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { children: "Telah Dibayarkan" })
				]
			}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
				className: role === "manager" ? "print-only" : "",
				children: e.status
			})] })
		] }, e.id)), !rows.length && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
			colSpan: 7,
			children: "Belum ada data."
		}) })] })] })
	});
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
		className: "report-sheet balance-sheet",
		children: [
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				className: "letterhead",
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", {
					src: "/logo.png",
					alt: "PT JLBB"
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: "PT. JASA LINGKUNGAN BAHARI BATAM" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Komplek Ruko Golden City Blok RI 17, Batam, Kepulauan Riau" })] })]
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				className: "balance-head",
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "LAPORAN KEUANGAN TERINTEGRASI" }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { children: "NERACA & LABA BERJALAN" }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: ["Posisi keuangan sampai dengan periode ", monthName(month)] }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
						className: `approval-state ${approval ? "approved" : "pending"}`,
						children: approval ? `Disetujui ${approval.approvedBy} · ${fmt$2(approval.approvedAt.slice(0, 10))}` : "Belum disetujui Direktur"
					})
				] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "balance-controls no-print",
					children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: ["Periode Bulan", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
							type: "month",
							value: month,
							onChange: (e) => setMonth(e.target.value)
						})] }),
						role === "director" && !approval && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
							className: "approve-button",
							onClick: () => onApprove("Neraca", month),
							children: "✓ Setujui Neraca"
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
							onClick: () => window.print(),
							children: "⇩ Download PDF"
						})
					]
				})]
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)("nav", {
				className: "balance-tabs no-print",
				children: [
					["summary", "Ringkasan Neraca"],
					["debts", "Hutang & Piutang"],
					["assets", "Aset & Aktiva"],
					["profit", "Laba Berjalan"]
				].map(([id, label]) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
					className: view === id ? "active" : "",
					onClick: () => setView(id),
					children: label
				}, id))
			}),
			view === "summary" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				className: "balance-section",
				children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "balance-kpis",
						children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { children: [
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "KAS & BANK" }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: rp$3(data.cash) }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "Penerimaan dikurangi pengeluaran terealisasi" })
							] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { children: [
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "PIUTANG USAHA" }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: rp$3(data.receivable) }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "Hak tagih yang belum diterima" })
							] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { children: [
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "ASET TETAP BERSIH" }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: rp$3(data.fixedAssets) }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "Estimasi nilai buku" })
							] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { children: [
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "HUTANG USAHA" }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: rp$3(data.payable) }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "Kewajiban belum dibayar" })
							] })
						]
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "balance-columns",
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: "AKTIVA / ASET" }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Kas dan bank" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: rp$3(data.cash) })] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Piutang usaha" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: rp$3(data.receivable) })] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Aset tetap—nilai buku" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: rp$3(data.fixedAssets) })] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
								className: "total",
								children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "TOTAL AKTIVA" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: rp$3(data.totalAssets) })]
							})
						] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: "KEWAJIBAN & EKUITAS" }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Hutang usaha" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: rp$3(data.payable) })] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Ekuitas / aset bersih" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: rp$3(data.equity) })] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
								className: "spacer",
								children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\xA0" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: "\xA0" })]
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
								className: "total",
								children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "TOTAL PASIVA" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: rp$3(data.payable + data.equity) })]
							})
						] })]
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "balance-check",
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Selisih keseimbangan neraca" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", {
							className: Math.abs(data.totalAssets - (data.payable + data.equity)) < 1 ? "positive" : "negative",
							children: rp$3(data.totalAssets - (data.payable + data.equity))
						})]
					})
				]
			}),
			view === "debts" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				className: "balance-section",
				children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "section-action no-print",
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: "Hutang & Piutang" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Saldo kewajiban dan hak tagih sampai akhir periode." })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
							onClick: () => onAdd("entry"),
							children: "＋ Tambah Hutang / Piutang"
						})]
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "debt-totals",
						children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { children: [
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "TOTAL PIUTANG" }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: rp$3(data.receivable) }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "Belum diterima" })
							] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { children: [
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "TOTAL HUTANG" }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: rp$3(data.payable) }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "Belum dibayar" })
							] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { children: [
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "SELISIH BERSIH" }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: rp$3(data.receivable - data.payable) }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "Piutang dikurangi hutang" })
							] })
						]
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", {
						className: "subsection-title",
						children: "Daftar Piutang"
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DebtTable, { rows: data.receivableRows }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", {
						className: "subsection-title",
						children: "Daftar Hutang"
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DebtTable, { rows: data.payableRows })
				]
			}),
			view === "assets" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				className: "balance-section",
				children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "section-action no-print",
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: "Register Aset & Aktiva" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Nilai perolehan dan estimasi nilai buku sampai akhir periode." })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
							onClick: () => onAdd("asset"),
							children: "＋ Tambah Aset"
						})]
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "asset-summary",
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Total nilai buku aset" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: rp$3(data.fixedAssets) })]
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "asset-grid balance-assets",
						children: [data.assetRows.map((a) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: a.code }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: a.condition })] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: a.name }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
								a.category,
								" • ",
								a.location
							] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("dl", { children: [
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: "Nilai perolehan" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: rp$3(a.acquisitionValue) })] }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: "Nilai buku periode" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: rp$3(data.bookValue(a)) })] }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: "Tanggal perolehan" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: fmt$2(a.acquisitionDate) })] })
							] })
						] }, a.id)), !data.assetRows.length && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
							className: "balance-empty",
							children: "Belum ada aset tercatat."
						})]
					})
				]
			}),
			view === "profit" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				className: "balance-section",
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "running-profit",
					children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "PENERIMAAN BULANAN" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: rp$3(data.revenue) })] }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "PENGELUARAN BULANAN" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: rp$3(data.expense) })] }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", {
							className: data.profit >= 0 ? "profit" : "loss",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "LABA / (RUGI) BERJALAN" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: rp$3(data.profit) })]
						})
					]
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("table", {
					className: "profit-table monthly-profit",
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tbody", { children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", {
							className: "section",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("th", { children: ["PENERIMAAN — ", monthName(month).toUpperCase()] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {})]
						}),
						data.monthly.filter((e) => e.direction === "Masuk" && e.category !== "Penawaran").map((e) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("td", { children: [e.description, /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("small", { children: [
							e.category,
							" • ",
							fmt$2(e.date)
						] })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: rp$3(e.paidAmount) })] }, e.id)),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", {
							className: "subtotal",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: "Total Penerimaan" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: rp$3(data.revenue) })]
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", {
							className: "section",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "PENGELUARAN" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {})]
						}),
						data.monthly.filter((e) => e.direction === "Keluar").map((e) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("td", { children: [e.description, /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("small", { children: [
							e.category,
							" • ",
							fmt$2(e.date)
						] })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("td", { children: [
							"(",
							rp$3(e.paidAmount),
							")"
						] })] }, e.id)),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", {
							className: "subtotal",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: "Total Pengeluaran" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("td", { children: [
								"(",
								rp$3(data.expense),
								")"
							] })]
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", {
							className: "grand",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: "LABA / (RUGI) BERJALAN" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: rp$3(data.profit) })]
						})
					] })
				})]
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				className: "balance-sign",
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Disusun oleh," }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "Bagian Keuangan" })
				] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
						"Batam, ",
						fmt$2(today$2),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
						"Disetujui oleh,"
					] }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "Andika Pratama, ST" }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "Direktur" })
				] })]
			})
		]
	});
}
//#endregion
//#region app/financial-forecast.tsx
var rp$2 = (n) => new Intl.NumberFormat("id-ID", {
	style: "currency",
	currency: "IDR",
	maximumFractionDigits: 0
}).format(n || 0), monthLabel = (key) => new Intl.DateTimeFormat("id-ID", {
	month: "long",
	year: "numeric"
}).format(/* @__PURE__ */ new Date(`${key}-01T00:00:00`)), monthKey = (offset) => {
	const d = /* @__PURE__ */ new Date();
	d.setDate(1);
	d.setMonth(d.getMonth() + offset);
	return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}`;
};
var scenarioRules = {
	Konservatif: {
		income: .9,
		expense: .95,
		growth: 0,
		description: "Target pendapatan lebih hati-hati dan pengeluaran dikendalikan 5% di bawah rata-rata."
	},
	Moderat: {
		income: 1,
		expense: 1,
		growth: .01,
		description: "Anggaran mengikuti rata-rata realisasi dengan pertumbuhan wajar 1% per bulan."
	},
	Agresif: {
		income: 1.2,
		expense: 1.15,
		growth: .03,
		description: "Target pertumbuhan pendapatan 20% dengan dukungan pengeluaran hingga 15% di atas rata-rata."
	}
};
var total = (rows) => rows.reduce((sum, row) => sum + row.budget, 0), actualTotal = (rows) => rows.reduce((sum, row) => sum + row.actual, 0);
function FinancialForecast({ entries, saved }) {
	const [scenario, setScenario] = (0, import_react.useState)("Moderat"), [planMonth, setPlanMonth] = (0, import_react.useState)(monthKey(1));
	const data = (0, import_react.useMemo)(() => {
		const actualMonth = monthKey(0), historyMonths = [
			-3,
			-2,
			-1
		].map(monthKey), monthDistance = Math.max(0, (Number(planMonth.slice(0, 4)) - (/* @__PURE__ */ new Date()).getFullYear()) * 12 + Number(planMonth.slice(5, 7)) - ((/* @__PURE__ */ new Date()).getMonth() + 2)), actualEntries = entries.filter((e) => e.date.startsWith(actualMonth)), historical = entries.filter((e) => historyMonths.some((month) => e.date.startsWith(month))), rule = scenarioRules[scenario], growth = Math.pow(1 + rule.growth, monthDistance), buildRows = (direction, defaults) => {
			return Array.from(new Set([
				...defaults,
				...historical.filter((e) => e.direction === direction && e.category !== "Penawaran").map((e) => e.category),
				...actualEntries.filter((e) => e.direction === direction && e.category !== "Penawaran").map((e) => e.category)
			])).map((category) => {
				const historyValue = historyMonths.reduce((sum, month) => sum + entries.filter((e) => e.date.startsWith(month) && e.direction === direction && e.category === category).reduce((a, e) => a + (e.paidAmount || 0), 0), 0) / 3, actual = actualEntries.filter((e) => e.direction === direction && e.category === category).reduce((a, e) => a + (e.paidAmount || 0), 0), budget = historyValue * (direction === "Masuk" ? rule.income : rule.expense) * growth;
				return {
					category,
					budget,
					actual,
					variance: direction === "Masuk" ? actual - budget : budget - actual,
					realization: budget ? actual / budget * 100 : 0
				};
			});
		};
		let incomeRows = buildRows("Masuk", [
			"Penerimaan",
			"Invoice",
			"Piutang"
		]), expenseRows = buildRows("Keluar", [
			"Pengeluaran",
			"Tagihan",
			"Hutang"
		]);
		const manual = saved.find((p) => p.period.slice(0, 7) === planMonth && p.scenario.toLowerCase() === scenario.toLowerCase());
		if (manual) {
			const incomeBase = total(incomeRows), expenseBase = total(expenseRows);
			incomeRows = incomeRows.map((row) => {
				const budget = incomeBase ? row.budget / incomeBase * manual.projectedIncome : 0;
				return {
					...row,
					budget,
					variance: row.actual - budget,
					realization: budget ? row.actual / budget * 100 : 0
				};
			});
			expenseRows = expenseRows.map((row) => {
				const budget = expenseBase ? row.budget / expenseBase * manual.projectedExpense : 0;
				return {
					...row,
					budget,
					variance: budget - row.actual,
					realization: budget ? row.actual / budget * 100 : 0
				};
			});
		}
		const budgetIncome = total(incomeRows), budgetExpense = total(expenseRows), actualIncome = actualTotal(incomeRows), actualExpense = actualTotal(expenseRows), compile = (name) => {
			const r = scenarioRules[name], savedPlan = saved.find((p) => p.period.slice(0, 7) === planMonth && p.scenario.toLowerCase() === name.toLowerCase()), baseIncome = historyMonths.reduce((sum, month) => sum + entries.filter((e) => e.date.startsWith(month) && e.direction === "Masuk" && e.category !== "Penawaran").reduce((a, e) => a + (e.paidAmount || 0), 0), 0) / 3, baseExpense = historyMonths.reduce((sum, month) => sum + entries.filter((e) => e.date.startsWith(month) && e.direction === "Keluar").reduce((a, e) => a + (e.paidAmount || 0), 0), 0) / 3, income = savedPlan?.projectedIncome ?? baseIncome * r.income * Math.pow(1 + r.growth, monthDistance), expense = savedPlan?.projectedExpense ?? baseExpense * r.expense * Math.pow(1 + r.growth, monthDistance);
			return {
				name,
				income,
				expense,
				profit: income - expense,
				actualProfit: actualIncome - actualExpense,
				achievement: income ? actualIncome / income * 100 : 0
			};
		};
		return {
			actualMonth,
			incomeRows,
			expenseRows,
			budgetIncome,
			budgetExpense,
			budgetProfit: budgetIncome - budgetExpense,
			actualIncome,
			actualExpense,
			actualProfit: actualIncome - actualExpense,
			manual,
			compiled: Object.keys(scenarioRules).map(compile)
		};
	}, [
		entries,
		saved,
		scenario,
		planMonth
	]);
	const DetailTable = ({ title, rows, direction }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
		className: "budget-detail",
		children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: title }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
			className: "table-wrap",
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("table", { children: [
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Jenis Transaksi" }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Anggaran" }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Realisasi Bulan Berjalan" }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Realisasi" }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Selisih" }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Status" })
				] }) }),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { children: rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: row.category }) }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: rp$2(row.budget) }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: rp$2(row.actual) }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "realization-cell",
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [row.realization.toFixed(1), "%"] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { style: { width: `${Math.min(100, row.realization)}%` } }) })]
					}) }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
						className: row.variance >= 0 ? "positive" : "negative",
						children: rp$2(row.variance)
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
						className: `budget-status ${direction === "income" ? row.realization >= 100 ? "good" : "watch" : row.realization <= 100 ? "good" : "bad"}`,
						children: direction === "income" ? row.realization >= 100 ? "Target tercapai" : "Di bawah target" : row.realization <= 100 ? "Terkendali" : "Melebihi anggaran"
					}) })
				] }, row.category)) }),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)("tfoot", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Total" }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: rp$2(total(rows)) }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: rp$2(actualTotal(rows)) }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("th", { children: [total(rows) ? (actualTotal(rows) / total(rows) * 100).toFixed(1) : "0.0", "%"] }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: rp$2(rows.reduce((s, r) => s + r.variance, 0)) }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {})
				] }) })
			] })
		})]
	});
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
		className: "panel page-panel financial-forecast budget-realization",
		children: [
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", {
				className: "finance-page-head",
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Perencanaan dan Pengendalian Anggaran" }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: "Anggaran vs Realisasi Keuangan" }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Anggaran terhubung langsung dengan realisasi Laporan Laba Rugi bulan berjalan." })
				] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "budget-controls",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: ["Bulan Anggaran", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
						type: "month",
						value: planMonth,
						onChange: (e) => setPlanMonth(e.target.value)
					})] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
						onClick: () => window.print(),
						children: "⇩ Cetak / PDF"
					})]
				})]
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				className: "scenario-tabs",
				children: Object.keys(scenarioRules).map((name) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
					className: scenario === name ? "active" : "",
					onClick: () => setScenario(name),
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: name }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: name === "Konservatif" ? "Kehati-hatian" : name === "Moderat" ? "Pertumbuhan wajar" : "Ekspansi tinggi" })]
				}, name))
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
				className: "scenario-note",
				children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("strong", { children: [
						"Anggaran ",
						scenario,
						" untuk ",
						monthLabel(planMonth),
						":"
					] }),
					" ",
					scenarioRules[scenario].description,
					" Realisasi pembanding berasal dari Laporan Laba Rugi ",
					monthLabel(data.actualMonth),
					".",
					data.manual && " Nilai total menggunakan penyesuaian manual yang tersimpan."
				]
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				className: "budget-summary",
				children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Pendapatan" }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "Anggaran" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: rp$2(data.budgetIncome) })] }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "Realisasi" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: rp$2(data.actualIncome) })] }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("em", { children: [data.budgetIncome ? (data.actualIncome / data.budgetIncome * 100).toFixed(1) : "0.0", "% tercapai"] })
					] }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Pengeluaran" }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "Anggaran" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: rp$2(data.budgetExpense) })] }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "Realisasi" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: rp$2(data.actualExpense) })] }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("em", { children: [data.budgetExpense ? (data.actualExpense / data.budgetExpense * 100).toFixed(1) : "0.0", "% terpakai"] })
					] }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", {
						className: data.budgetProfit >= 0 ? "profit" : "loss",
						children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Laba / (Rugi)" }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "Anggaran" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: rp$2(data.budgetProfit) })] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "Realisasi berjalan" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: rp$2(data.actualProfit) })] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("em", { children: [data.budgetProfit ? Math.abs(data.actualProfit / data.budgetProfit * 100).toFixed(1) : "0.0", "% terhadap rencana"] })
						]
					})
				]
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DetailTable, {
				title: "Rencana dan Realisasi Pendapatan",
				rows: data.incomeRows,
				direction: "income"
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DetailTable, {
				title: "Rencana dan Realisasi Pengeluaran",
				rows: data.expenseRows,
				direction: "expense"
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
				className: "scenario-compile",
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: "Kompilasi Tiga Skenario" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
					"Perbandingan anggaran ",
					monthLabel(planMonth),
					" dengan realisasi laba rugi ",
					monthLabel(data.actualMonth),
					"."
				] })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
					className: "table-wrap",
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("table", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Skenario" }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Anggaran Pendapatan" }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Anggaran Pengeluaran" }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Proyeksi Laba / (Rugi)" }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Realisasi Laba / (Rugi)" }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Pencapaian Pendapatan" })
					] }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { children: data.compiled.map((row) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", {
						className: row.name === scenario ? "selected-scenario" : "",
						children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: row.name }) }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: rp$2(row.income) }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: rp$2(row.expense) }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
								className: row.profit >= 0 ? "positive" : "negative",
								children: rp$2(row.profit)
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
								className: row.actualProfit >= 0 ? "positive" : "negative",
								children: rp$2(row.actualProfit)
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("td", { children: [row.achievement.toFixed(1), "%"] })
						]
					}, row.name)) })] })
				})]
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
				className: "budget-method",
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "Metode:" }), " nilai dasar dihitung dari rata-rata realisasi tiga bulan terakhir per jenis transaksi. Anggaran manual yang tersimpan untuk bulan dan skenario yang sama digunakan sebagai pengganti total otomatis lalu dialokasikan secara proporsional ke setiap jenis transaksi."]
			})
		]
	});
}
//#endregion
//#region app/operational-views.tsx
var today$1 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), yearStart = `${(/* @__PURE__ */ new Date()).getFullYear()}-01-01`, rp$1 = (n) => new Intl.NumberFormat("id-ID", {
	style: "currency",
	currency: "IDR",
	maximumFractionDigits: 0
}).format(n || 0), fmt$1 = (d) => new Intl.DateTimeFormat("id-ID", {
	day: "2-digit",
	month: "short",
	year: "numeric"
}).format(/* @__PURE__ */ new Date(d + "T00:00:00"));
function Range({ from, to, setFrom, setTo }) {
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
		className: "date-range",
		children: [
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: ["Dari", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
				type: "date",
				value: from,
				onChange: (e) => setFrom(e.target.value)
			})] }),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "—" }),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: ["Sampai", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
				type: "date",
				value: to,
				onChange: (e) => setTo(e.target.value)
			})] })
		]
	});
}
function CompactTransactions({ entries, onDelete }) {
	const [from, setFrom] = (0, import_react.useState)(yearStart), [to, setTo] = (0, import_react.useState)(today$1), rows = entries.filter((e) => e.date >= from && e.date <= to && !["Penawaran"].includes(e.category)), incoming = rows.filter((e) => e.direction === "Masuk"), outgoing = rows.filter((e) => e.direction === "Keluar");
	const Ledger = ({ title, list, tone }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", {
		className: `ledger-half ${tone}`,
		children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: title }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: rp$1(list.reduce((a, e) => a + (e.paidAmount || e.amount), 0)) })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("table", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Tanggal" }),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Jenis transaksi" }),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Jumlah" }),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {})
		] }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tbody", { children: [list.map((e, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: fmt$1(e.date) }),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("td", { children: [
				i + 1,
				". ",
				e.category,
				" — ",
				e.description
			] }),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: rp$1(e.paidAmount || e.amount) }),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
				onClick: () => onDelete(e.id, e.description),
				children: "Hapus"
			}) })
		] }, e.id)), !list.length && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
			colSpan: 4,
			children: "Tidak ada transaksi."
		}) })] })] })]
	});
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
		className: "panel page-panel compact-ledger",
		children: [
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				className: "page-head",
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: "Rekap Transaksi" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Pemasukan dan pengeluaran dalam satu compile" })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Range, {
					from,
					to,
					setFrom,
					setTo
				})]
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				className: "dual-ledger",
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Ledger, {
					title: "PEMASUKAN",
					list: incoming,
					tone: "income-ledger"
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Ledger, {
					title: "PENGELUARAN",
					list: outgoing,
					tone: "expense-ledger"
				})]
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				className: "ledger-net",
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "SELISIH BERSIH" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", {
					className: incoming.reduce((a, e) => a + (e.paidAmount || e.amount), 0) - outgoing.reduce((a, e) => a + (e.paidAmount || e.amount), 0) >= 0 ? "positive" : "negative",
					children: rp$1(incoming.reduce((a, e) => a + (e.paidAmount || e.amount), 0) - outgoing.reduce((a, e) => a + (e.paidAmount || e.amount), 0))
				})]
			})
		]
	});
}
function ClientDirectory({ items, projects, onDelete }) {
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
		className: "panel page-panel",
		children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
			className: "page-head",
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: "Database Klien & Perusahaan" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Nomor urut otomatis dan rekaman relasi proyek" })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
				className: "count-chip",
				children: [items.length, " perusahaan"]
			})]
		}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
			className: "client-grid numbered-clients",
			children: items.map((c, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { children: [
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
					className: "row-number",
					children: String(i + 1).padStart(2, "0")
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
					className: "avatar",
					children: c.company.replace("PT.", "").trim().slice(0, 2).toUpperCase()
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: c.company }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: c.contact || "Kontak belum diisi" }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("small", { children: [
						c.phone || "—",
						" • ",
						c.email || "—"
					] }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [projects.filter((p) => p.clientId === c.id).length, " proyek tercatat"] })
				] }),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
					className: "delete-btn",
					onClick: () => onDelete("client", c.id, c.company),
					children: "Hapus"
				})
			] }, c.id))
		})]
	});
}
function StandardProfitReport({ entries, projects, approvals, role, onApprove }) {
	const [selectedMonth, setSelectedMonth] = (0, import_react.useState)(today$1.slice(0, 7)), year = selectedMonth.slice(0, 4), monthRows = entries.filter((e) => e.date.startsWith(selectedMonth)), revenueRows = monthRows.filter((e) => e.direction === "Masuk" && e.category !== "Penawaran"), expenseRows = monthRows.filter((e) => e.direction === "Keluar"), serviceRevenue = revenueRows.filter((e) => ["Penerimaan", "Invoice"].includes(e.category)).reduce((a, e) => a + e.paidAmount, 0), otherRevenue = revenueRows.filter((e) => !["Penerimaan", "Invoice"].includes(e.category)).reduce((a, e) => a + e.paidAmount, 0), projectExpense = expenseRows.filter((e) => e.category === "Pengeluaran").reduce((a, e) => a + e.paidAmount, 0), otherExpense = expenseRows.filter((e) => e.category !== "Pengeluaran").reduce((a, e) => a + e.paidAmount, 0), revenue = serviceRevenue + otherRevenue, expense = projectExpense + otherExpense, profit = revenue - expense, monthTitle = new Intl.DateTimeFormat("id-ID", {
		month: "long",
		year: "numeric"
	}).format(/* @__PURE__ */ new Date(`${selectedMonth}-01T00:00:00`));
	const annual = Array.from({ length: 12 }, (_, index) => {
		const key = `${year}-${String(index + 1).padStart(2, "0")}`, rows = entries.filter((e) => e.date.startsWith(key)), income = rows.filter((e) => e.direction === "Masuk" && e.category !== "Penawaran").reduce((a, e) => a + e.paidAmount, 0), cost = rows.filter((e) => e.direction === "Keluar").reduce((a, e) => a + e.paidAmount, 0);
		return {
			key,
			label: new Intl.DateTimeFormat("id-ID", { month: "long" }).format(/* @__PURE__ */ new Date(`${key}-01T00:00:00`)),
			income,
			cost,
			profit: income - cost
		};
	}), annualIncome = annual.reduce((s, m) => s + m.income, 0), annualExpense = annual.reduce((s, m) => s + m.cost, 0), approval = approvals.find((a) => a.reportType === "Laba Rugi" && a.period === selectedMonth);
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
		className: "report-sheet standard-report monthly-profit-report",
		children: [
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				className: "letterhead",
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", {
					src: "/logo.png",
					alt: "PT JLBB"
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: "PT. Jasa Lingkungan Bahari Batam" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Komplek Ruko Golden City Blok RI 17, Batam, Kepulauan Riau" })] })]
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				className: "report-heading",
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Laporan Keuangan Bulanan" }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { children: "Laporan Laba Rugi" }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: ["Untuk periode ", monthTitle] }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
						className: `approval-state ${approval ? "approved" : "pending"}`,
						children: approval ? `Disetujui ${approval.approvedBy} · ${fmt$1(approval.approvedAt.slice(0, 10))}` : "Belum disetujui Direktur"
					})
				] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "monthly-report-controls",
					children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: ["Periode Bulan", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
							type: "month",
							value: selectedMonth,
							onChange: (e) => setSelectedMonth(e.target.value)
						})] }),
						role === "director" && !approval && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
							className: "approve-button",
							onClick: () => onApprove("Laba Rugi", selectedMonth),
							children: "✓ Setujui Laporan"
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
							onClick: () => window.print(),
							children: "⇩ Cetak / PDF"
						})
					]
				})]
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				className: "report-meta",
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Basis pencatatan: transaksi kas terealisasi" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: ["Tanggal cetak: ", fmt$1(today$1)] })]
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)("table", {
				className: "profit-table",
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tbody", { children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", {
						className: "section",
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Pendapatan" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {})]
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: "Pendapatan jasa dan proyek" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: rp$1(serviceRevenue) })] }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: "Pendapatan lain-lain" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: rp$1(otherRevenue) })] }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", {
						className: "subtotal",
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: "Total Pendapatan" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: rp$1(revenue) })]
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", {
						className: "section",
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Beban" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {})]
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: "Beban proyek dan operasional" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("td", { children: [
						"(",
						rp$1(projectExpense),
						")"
					] })] }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: "Beban lain-lain dan pembayaran kewajiban" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("td", { children: [
						"(",
						rp$1(otherExpense),
						")"
					] })] }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", {
						className: "subtotal",
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: "Total Beban" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("td", { children: [
							"(",
							rp$1(expense),
							")"
						] })]
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", {
						className: "grand",
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: "Laba / (Rugi) Bersih" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
							className: profit >= 0 ? "positive" : "negative",
							children: rp$1(profit)
						})]
					})
				] })
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
				className: "annual-compile",
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h3", { children: ["Rekap Laba Rugi Bulanan Tahun ", year] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Kompilasi otomatis dari transaksi setiap bulan." })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
					className: "table-wrap",
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("table", { children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Bulan" }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Pendapatan" }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Beban" }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Laba / (Rugi)" }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Margin" })
						] }) }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { children: annual.map((m) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", {
							className: m.key === selectedMonth ? "selected-month" : "",
							children: [
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: m.label }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: rp$1(m.income) }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: rp$1(m.cost) }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
									className: m.profit >= 0 ? "positive" : "negative",
									children: rp$1(m.profit)
								}),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("td", { children: [m.income ? (m.profit / m.income * 100).toFixed(1) : "0.0", "%"] })
							]
						}, m.key)) }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("tfoot", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("th", { children: ["Total Tahun ", year] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: rp$1(annualIncome) }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: rp$1(annualExpense) }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {
								className: annualIncome - annualExpense >= 0 ? "positive" : "negative",
								children: rp$1(annualIncome - annualExpense)
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("th", { children: [annualIncome ? ((annualIncome - annualExpense) / annualIncome * 100).toFixed(1) : "0.0", "%"] })
						] }) })
					] })
				})]
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				className: "report-projects",
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: "Lampiran Ringkas Proyek" }), projects.map((p, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
						i + 1,
						". ",
						p.name
					] }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [p.progress, "%"] }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: rp$1(p.contractValue) })
				] }, p.id))]
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				className: "signature",
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Disusun oleh," }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "Bagian Keuangan" })
				] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
						"Batam, ",
						fmt$1(today$1),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
						"Disetujui oleh,"
					] }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "Andika Pratama, ST" }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "Direktur" })
				] })]
			})
		]
	});
}
//#endregion
//#region app/page.tsx
var empty = {
	clients: [],
	projects: [],
	entries: [],
	assets: [],
	projections: [],
	approvals: []
};
var menus = [
	[
		"dashboard",
		"Ringkasan",
		"⌂"
	],
	[
		"transactions",
		"Transaksi",
		"↕"
	],
	[
		"balance",
		"Neraca",
		"▤"
	],
	[
		"offers",
		"Buat Penawaran",
		"⌑"
	],
	[
		"billing",
		"Tagihan & Kwitansi",
		"▣"
	],
	[
		"projects",
		"Profit Proyek",
		"◫"
	],
	[
		"forecast",
		"Proyeksi Keuangan",
		"⌁"
	],
	[
		"clients",
		"Data Klien",
		"♙"
	],
	[
		"reports",
		"Laporan Laba Rugi",
		"▥"
	],
	[
		"notifications",
		"Notifikasi",
		"●"
	]
];
var rp = (n) => new Intl.NumberFormat("id-ID", {
	style: "currency",
	currency: "IDR",
	maximumFractionDigits: 0
}).format(n || 0);
var today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
var fmt = (d) => d ? new Intl.DateTimeFormat("id-ID", {
	day: "2-digit",
	month: "short",
	year: "numeric"
}).format(/* @__PURE__ */ new Date(d + "T00:00:00")) : "—";
function Home() {
	const [tab, setTab] = (0, import_react.useState)("dashboard"), [data, setData] = (0, import_react.useState)(empty), [loading, setLoading] = (0, import_react.useState)(true), [session, setSession] = (0, import_react.useState)(null), [authReady, setAuthReady] = (0, import_react.useState)(false), [modal, setModal] = (0, import_react.useState)(null), [toast, setToast] = (0, import_react.useState)(""), [query, setQuery] = (0, import_react.useState)(""), [period, setPeriod] = (0, import_react.useState)("all");
	const reload = async () => {
		setLoading(true);
		try {
			const r = await fetch("/api/finance", { cache: "no-store" });
			if (r.status === 401) {
				setSession(null);
				return;
			}
			setData(await r.json());
		} finally {
			setLoading(false);
		}
	};
	(0, import_react.useEffect)(() => {
		fetch("/api/auth", { cache: "no-store" }).then(async (r) => {
			if (r.ok) {
				setSession((await r.json()).user);
				await reload();
			}
		}).finally(() => {
			setAuthReady(true);
			setLoading(false);
		});
	}, []);
	const post = async (kind, payload) => {
		const r = await fetch("/api/finance", {
			method: "POST",
			headers: { "Content-Type": "application/json" },
			body: JSON.stringify({
				kind,
				...payload
			})
		});
		if (!r.ok) throw new Error((await r.json()).error || "Gagal menyimpan");
		await reload();
		setModal(null);
		setToast("Data berhasil disimpan ke database");
		setTimeout(() => setToast(""), 3e3);
	};
	const remove = async (kind, id, name) => {
		if (!window.confirm(`Hapus ${name}? Data yang sudah terhubung dengan transaksi tidak dapat dihapus.`)) return;
		const r = await fetch(`/api/finance?kind=${kind}&id=${id}`, { method: "DELETE" }), j = await r.json();
		if (!r.ok) {
			setToast(j.error || "Gagal menghapus data");
			setTimeout(() => setToast(""), 4500);
			return;
		}
		await reload();
		setToast(`${name} berhasil dihapus.`);
		setTimeout(() => setToast(""), 3e3);
	};
	const deleteEntry = async (id, name) => {
		if (!window.confirm(`Hapus transaksi ${name}?`)) return;
		const r = await fetch(`/api/finance?kind=entry&id=${id}`, { method: "DELETE" }), j = await r.json();
		setToast(r.ok ? "Transaksi berhasil dihapus." : j.error || "Gagal menghapus transaksi");
		if (r.ok) await reload();
		setTimeout(() => setToast(""), 4500);
	};
	const updateEntryStatus = async (entry, status) => {
		const r = await fetch("/api/finance", {
			method: "POST",
			headers: { "Content-Type": "application/json" },
			body: JSON.stringify({
				kind: "entryStatus",
				id: entry.id,
				status,
				amount: entry.amount,
				paidAmount: entry.paidAmount
			})
		}), j = await r.json();
		setToast(r.ok ? `Tahapan diperbarui menjadi ${status}.` : j.error || "Gagal memperbarui tahapan");
		if (r.ok) await reload();
		setTimeout(() => setToast(""), 3e3);
	};
	const dismissNotification = async (id) => {
		await fetch(`/api/finance?kind=notification&id=${id}`, { method: "DELETE" });
		await reload();
		setToast("Notifikasi dihapus tanpa menghapus transaksi sumber.");
		setTimeout(() => setToast(""), 3e3);
	};
	const updateProject = async (id, payload) => {
		const r = await fetch("/api/finance", {
			method: "POST",
			headers: { "Content-Type": "application/json" },
			body: JSON.stringify({
				kind: "projectUpdate",
				id,
				...payload
			})
		}), j = await r.json();
		setToast(r.ok ? "Data proyek berhasil diperbarui." : j.error || "Gagal memperbarui proyek");
		if (r.ok) await reload();
		setTimeout(() => setToast(""), 3500);
		return r.ok;
	};
	const approve = async (reportType, approvalPeriod) => {
		const r = await fetch("/api/finance", {
			method: "POST",
			headers: { "Content-Type": "application/json" },
			body: JSON.stringify({
				kind: "approval",
				reportType,
				period: approvalPeriod
			})
		}), j = await r.json();
		setToast(r.ok ? `${reportType} periode ${approvalPeriod} telah disetujui.` : j.error || "Persetujuan gagal");
		if (r.ok) await reload();
		setTimeout(() => setToast(""), 4e3);
	};
	const logout = async () => {
		await fetch("/api/auth", { method: "DELETE" });
		setSession(null);
		setData(empty);
		setTab("dashboard");
	};
	const now = /* @__PURE__ */ new Date();
	(0, import_react.useMemo)(() => data.entries.filter((e) => {
		const s = `${e.documentNo} ${e.description} ${e.clientName} ${e.projectName}`.toLowerCase().includes(query.toLowerCase());
		if (period === "all") return s;
		const d = /* @__PURE__ */ new Date(e.date + "T00:00:00");
		if (period === "week") {
			const x = new Date(now);
			x.setDate(now.getDate() - 7);
			return s && d >= x;
		}
		if (period === "month") return s && d.getMonth() === now.getMonth() && d.getFullYear() === now.getFullYear();
		return s && d.getFullYear() === Number(period);
	}), [
		data.entries,
		query,
		period
	]);
	const income = data.entries.filter((e) => e.direction === "Masuk" && e.category !== "Penawaran").reduce((a, e) => a + e.paidAmount, 0), expense = data.entries.filter((e) => e.direction === "Keluar").reduce((a, e) => a + e.paidAmount, 0);
	const receivable = data.entries.filter((e) => e.direction === "Masuk" && ["Invoice", "Piutang"].includes(e.category)).reduce((a, e) => a + Math.max(0, e.amount - e.paidAmount), 0), payable = data.entries.filter((e) => e.direction === "Keluar" && ["Hutang", "Tagihan"].includes(e.category)).reduce((a, e) => a + Math.max(0, e.amount - e.paidAmount), 0);
	const alerts = data.entries.filter((e) => e.dueDate && !e.notificationDismissed && ![
		"Lunas",
		"Ditolak",
		"Telah Dibayarkan"
	].includes(e.status)).map((e) => ({
		...e,
		days: Math.ceil(((/* @__PURE__ */ new Date(e.dueDate + "T00:00:00")).getTime() - (/* @__PURE__ */ new Date(today + "T00:00:00")).getTime()) / 864e5)
	})).filter((e) => e.days <= 14).sort((a, b) => a.days - b.days);
	const addKind = tab === "clients" ? "client" : tab === "projects" ? "project" : tab === "assets" ? "asset" : tab === "forecast" ? "projection" : "entry";
	if (!authReady) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
		className: "auth-loading",
		children: "Menyiapkan keamanan JLBB…"
	});
	if (!session) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Login, { onLogin: async (user) => {
		setSession(user);
		setAuthReady(true);
		await reload();
	} });
	const visibleMenus = session.role === "director" ? menus.filter((m) => [
		"dashboard",
		"balance",
		"reports"
	].includes(m[0])) : menus;
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
		className: "app-shell",
		children: [
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("aside", {
				className: "sidebar",
				children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "brand",
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", {
							src: "/logo.png",
							alt: "Logo PT JLBB"
						}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "JLBB" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Finance & Profit Control" })] })]
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("nav", { children: visibleMenus.map(([id, label, icon]) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
						className: tab === id ? "active" : "",
						onClick: () => setTab(id),
						children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { children: icon }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: label }),
							id === "notifications" && alerts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: alerts.length })
						]
					}, id)) }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "side-foot",
						children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: session.role === "director" ? "DP" : "MK" }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: session.name }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: session.role === "director" ? "Direktur · Persetujuan" : "Manager · Operasional" })] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
								className: "logout-button",
								onClick: logout,
								title: "Keluar",
								children: "↪"
							})
						]
					})
				]
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("main", {
				className: "workspace",
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", {
					className: "topbar",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "JLBB Finance & Profit Control" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { children: menus.find((m) => m[0] === tab)?.[1] })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "top-actions",
						children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
								className: "search",
								children: ["⌕", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
									placeholder: "Cari dokumen, klien, proyek...",
									value: query,
									onChange: (e) => setQuery(e.target.value)
								})]
							}),
							session.role === "manager" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
								className: "bell",
								onClick: () => setTab("notifications"),
								children: ["♢", alerts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("em", { children: alerts.length })]
							}),
							session.role === "manager" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
								className: "primary",
								onClick: () => ["offers", "billing"].includes(tab) ? window.dispatchEvent(new Event("open-document-builder")) : setModal(addKind),
								children: ["＋ ", ["offers", "billing"].includes(tab) ? "Dokumen Baru" : "Tambah Data"]
							})
						]
					})]
				}), loading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
					className: "loading",
					children: "Menghubungkan data keuangan…"
				}) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "content",
					children: [
						tab === "dashboard" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinanceDashboard, {
							data,
							income,
							expense,
							receivable,
							payable,
							alerts,
							go: setTab
						}),
						tab === "transactions" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CompactTransactions, {
							entries: data.entries,
							onDelete: deleteEntry
						}),
						tab === "offers" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DocumentBuilder, {
							mode: "Penawaran",
							clients: data.clients,
							projects: data.projects
						}),
						tab === "billing" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DocumentBuilder, {
							mode: "Tagihan",
							clients: data.clients,
							projects: data.projects
						}),
						tab === "balance" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BalanceSheet, {
							entries: data.entries,
							assets: data.assets,
							approvals: data.approvals,
							role: session.role,
							onApprove: approve,
							onStatus: updateEntryStatus,
							onAdd: (kind) => setModal(kind)
						}),
						tab === "projects" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ProjectServices, {
							projects: data.projects,
							entries: data.entries,
							onDelete: remove,
							onEdit: updateProject
						}),
						" ",
						tab === "forecast" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialForecast, {
							entries: data.entries,
							saved: data.projections
						}),
						" ",
						tab === "clients" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ClientDirectory, {
							items: data.clients,
							projects: data.projects,
							onDelete: remove
						}),
						" ",
						tab === "reports" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StandardProfitReport, {
							entries: data.entries,
							projects: data.projects,
							approvals: data.approvals,
							role: session.role,
							onApprove: approve
						}),
						" ",
						tab === "notifications" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Notifications, {
							alerts,
							onDismiss: dismissNotification
						})
					]
				})]
			}),
			modal && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Modal, {
				kind: modal,
				data,
				close: () => setModal(null),
				save: post
			}),
			" ",
			toast && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				className: "toast",
				children: ["✓ ", toast]
			})
		]
	});
}
function Login({ onLogin }) {
	const [username, setUsername] = (0, import_react.useState)(""), [password, setPassword] = (0, import_react.useState)(""), [error, setError] = (0, import_react.useState)(""), [busy, setBusy] = (0, import_react.useState)(false);
	const submit = async (e) => {
		e.preventDefault();
		setBusy(true);
		setError("");
		try {
			const r = await fetch("/api/auth", {
				method: "POST",
				headers: { "Content-Type": "application/json" },
				body: JSON.stringify({
					username,
					password
				})
			}), j = await r.json();
			if (!r.ok) throw new Error(j.error || "Login gagal");
			await onLogin(j.user);
		} catch (x) {
			setError(x instanceof Error ? x.message : "Login gagal");
		} finally {
			setBusy(false);
		}
	};
	return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("main", {
		className: "login-page",
		children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
			className: "login-card",
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				className: "login-brand",
				children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", {
						src: "/logo.png",
						alt: "PT JLBB"
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "JLBB Finance & Profit Control" }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { children: "Masuk ke sistem keuangan" }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Akses data, dokumen, laporan, dan persetujuan sesuai peran akun." })
				]
			}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", {
				onSubmit: submit,
				children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Nama pengguna" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
						autoFocus: true,
						autoComplete: "username",
						value: username,
						onChange: (e) => setUsername(e.target.value),
						placeholder: "Masukkan nama pengguna"
					})] }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Kata sandi" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
						type: "password",
						autoComplete: "current-password",
						value: password,
						onChange: (e) => setPassword(e.target.value),
						placeholder: "Masukkan kata sandi"
					})] }),
					error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
						className: "login-error",
						children: error
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
						disabled: busy || !username || !password,
						children: busy ? "Memeriksa…" : "Masuk Aman"
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "Sesi otomatis berakhir setelah 8 jam. Gunakan akun sesuai wewenang kerja." })
				]
			})]
		})
	});
}
function Notifications({ alerts, onDismiss }) {
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
		className: "panel page-panel",
		children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
			className: "page-head",
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: "Pusat Notifikasi Jatuh Tempo" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Pengingat transaksi, tagihan, hutang, dan piutang" })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
				className: "count-chip warning",
				children: [alerts.length, " perlu perhatian"]
			})]
		}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
			className: "notification-list",
			children: [alerts.map((a) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", {
				className: a.days < 0 ? "overdue" : "",
				children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: a.days < 0 ? "TERLAMBAT" : a.days === 0 ? "HARI INI" : `${a.days} HARI LAGI` }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: a.description }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
						a.documentNo,
						" • ",
						a.clientName || a.projectName || "Transaksi umum"
					] })] }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: rp(a.amount - a.paidAmount) }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("small", { children: ["Jatuh tempo ", fmt(a.dueDate)] }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
							className: "dismiss-btn",
							onClick: () => onDismiss(a.id),
							children: "Hapus Notifikasi"
						})
					] })
				]
			}, a.id)), !alerts.length && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Empty, { text: "Semua transaksi aman." })]
		})]
	});
}
function Empty({ text }) {
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
		className: "empty",
		children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "◎" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: text })]
	});
}
function Modal({ kind, data, close, save }) {
	const [saving, setSaving] = (0, import_react.useState)(false), [error, setError] = (0, import_react.useState)("");
	const submit = async (e) => {
		e.preventDefault();
		setSaving(true);
		setError("");
		try {
			await save(kind, Object.fromEntries(new FormData(e.currentTarget).entries()));
		} catch (x) {
			setError(x instanceof Error ? x.message : "Gagal menyimpan");
			setSaving(false);
		}
	};
	return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
		className: "modal-backdrop",
		onMouseDown: (e) => e.target === e.currentTarget && close(),
		children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", {
			className: "modal",
			onSubmit: submit,
			children: [
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "modal-head",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "FORMULIR DATABASE" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h2", { children: ["Tambah ", kind === "entry" ? "Catatan Keuangan" : kind === "client" ? "Klien" : kind === "project" ? "Proyek" : kind === "asset" ? "Aset" : "Proyeksi"] })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
						type: "button",
						onClick: close,
						children: "×"
					})]
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "form-grid",
					children: [
						kind === "entry" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
								label: "Tanggal",
								name: "date",
								type: "date",
								value: today
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
								label: "Jatuh tempo",
								name: "dueDate",
								type: "date"
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Nomor transaksi" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
								value: "Otomatis saat disimpan",
								disabled: true
							})] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
								label: "Kategori",
								name: "category",
								options: [
									"Penerimaan",
									"Pengeluaran",
									"Penawaran",
									"Invoice",
									"Piutang",
									"Hutang",
									"Tagihan"
								]
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
								label: "Arah transaksi",
								name: "direction",
								options: ["Masuk", "Keluar"]
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
								label: "Status",
								name: "status",
								options: [
									"Draft",
									"Diajukan",
									"Menunggu",
									"Disetujui",
									"Sebagian",
									"Lunas",
									"Ditolak"
								]
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
								wide: true,
								label: "Uraian",
								name: "description",
								required: true
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
								label: "Nilai transaksi",
								name: "amount",
								type: "number",
								required: true
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
								label: "Sudah dibayar",
								name: "paidAmount",
								type: "number",
								value: "0"
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
								label: "Klien",
								name: "clientId",
								options: ["", ...data.clients.map((c) => `${c.id}|${c.company}`)]
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
								label: "Proyek",
								name: "projectId",
								options: ["", ...data.projects.map((p) => `${p.id}|${p.name}`)]
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
								wide: true,
								label: "Catatan",
								name: "notes"
							})
						] }),
						kind === "client" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
								wide: true,
								label: "Nama perusahaan",
								name: "company",
								required: true
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
								label: "Nama kontak / PIC",
								name: "contact"
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
								label: "Telepon / WhatsApp",
								name: "phone"
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
								label: "Email",
								name: "email",
								type: "email"
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
								label: "NPWP",
								name: "taxId"
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
								wide: true,
								label: "Alamat",
								name: "address"
							})
						] }),
						kind === "project" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Kode proyek" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
								value: "Otomatis saat disimpan",
								disabled: true
							})] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
								label: "Klien",
								name: "clientId",
								options: ["", ...data.clients.map((c) => `${c.id}|${c.company}`)]
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
								wide: true,
								label: "Jenis layanan proyek",
								name: "serviceType",
								options: ["", ...SERVICE_NAMES]
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
								wide: true,
								label: "Nama proyek",
								name: "name",
								required: true
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
								label: "Nilai kontrak",
								name: "contractValue",
								type: "number"
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
								label: "Anggaran biaya",
								name: "budget",
								type: "number"
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
								label: "Progres (%)",
								name: "progress",
								type: "number",
								value: "0"
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
								label: "Status",
								name: "status",
								options: [
									"Perencanaan",
									"Berjalan",
									"Tertunda",
									"Selesai",
									"Berhenti / Tidak Dilanjutkan"
								]
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
								label: "Mulai",
								name: "startDate",
								type: "date"
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
								label: "Target selesai",
								name: "endDate",
								type: "date"
							})
						] }),
						kind === "asset" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Kode aset" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
								value: "Otomatis saat disimpan",
								disabled: true
							})] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
								label: "Nama aset",
								name: "name",
								required: true
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
								label: "Kategori",
								name: "category",
								options: [
									"Kendaraan",
									"Peralatan Kantor",
									"Peralatan Lapangan",
									"Komputer & Elektronik",
									"Aktiva Lain"
								]
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
								label: "Tanggal perolehan",
								name: "acquisitionDate",
								type: "date",
								required: true
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
								label: "Nilai perolehan",
								name: "acquisitionValue",
								type: "number"
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
								label: "Umur manfaat (tahun)",
								name: "usefulLife",
								type: "number",
								value: "4"
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
								label: "Kondisi",
								name: "condition",
								options: [
									"Baik",
									"Perlu Perawatan",
									"Rusak"
								]
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
								label: "Lokasi",
								name: "location",
								value: "Kantor JLBB"
							})
						] }),
						kind === "projection" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
								label: "Periode",
								name: "period",
								type: "month",
								required: true
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
								label: "Skenario",
								name: "scenario",
								options: [
									"Konservatif",
									"Moderat",
									"Agresif"
								]
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
								label: "Proyeksi pendapatan",
								name: "projectedIncome",
								type: "number"
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
								label: "Proyeksi pengeluaran",
								name: "projectedExpense",
								type: "number"
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
								wide: true,
								label: "Asumsi atau catatan",
								name: "notes"
							})
						] })
					]
				}),
				error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
					className: "form-error",
					children: error
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "modal-actions",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
						type: "button",
						onClick: close,
						children: "Batal"
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
						className: "primary",
						disabled: saving,
						children: saving ? "Menyimpan…" : "Simpan ke Database"
					})]
				})
			]
		})
	});
}
function Field({ label, name, type = "text", value, placeholder, required, wide }) {
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
		className: wide ? "wide" : "",
		children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [label, required && " *"] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
			name,
			type,
			defaultValue: value,
			placeholder,
			required
		})]
	});
}
function Select({ label, name, options, wide }) {
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
		className: wide ? "wide" : "",
		children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: label }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", {
			name,
			children: options.map((o) => {
				const [v, t] = o.includes("|") ? o.split("|") : [o, o || "— Pilih —"];
				return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
					value: v,
					children: t
				}, o);
			})
		})]
	});
}
//#endregion
export { Home as default };
