local J=require("\064\108\117\110\101\047\102\115")local T=require("\064\108\117\110\101\047\112\114\111\099\101\115\115")local c=require("\109\111\100\117\108\101\115\047\066\117\105\108\100\067\111\100\101\103\101\110")local V="\100\105\115\116\047\109\097\105\110\046\108\117\097"local M="\100\105\115\116\047\116\101\109\112\046\108\117\097"local v=J.readFile("\098\117\105\108\100\047\104\101\097\100\101\114\046\108\117\097\117")local function j(c)J.writeFile(M,c)T.spawn("\100\097\114\107\108\117\097",{"\112\114\111\099\101\115\115",M,M;"--\099\111\110\102\105\103","\098\117\105\108\100\047\100\097\114\107\108\117\097\046\106\115\111\110"})local V=J.readFile(M)J.removeFile(M)return V end local Z=J.readFile("\100\105\115\116\047\109\097\105\110\046\114\098\120\109")local y=c(Z,false)J.writeFile(V,v..("\n"..j(y)))
local fs = require("@lune/fs")
local process = require("@lune/process")
local BuildCodegen = require("modules/BuildCodegen")

local FilePath = "dist/main.lua"
local TempFile = "dist/temp.lua"
local Header = fs.readFile("build/header.luau")

local function minify(text)
	fs.writeFile(TempFile, text)
    process.spawn("darklua", {"process", TempFile, TempFile, "--config", "build/darklua.json"})
	local value = fs.readFile(TempFile)
	fs.removeFile(TempFile)
	return value
end

local Module = fs.readFile("dist/main.rbxm")
local ModelCodegen = BuildCodegen(Module, false)

fs.writeFile(FilePath, Header .. "\n" .. minify(ModelCodegen))