-- Decompiled with the Synapse X Luau decompiler.


local v1 = require(game.ReplicatedStorage:WaitForChild("Resources"));
while not v1.Loaded do
	game:GetService("RunService").Heartbeat:Wait();
end;
function TurnAutoHacth(p1, p2)
	v1.Variables.AutoHatchEnabled = p1;
	v1.Signal.Fire("Auto Hatch Updated");
	if p2 then
		v1.Variables.AutoHatchEggId = p2;
		return;
	end;
	v1.Variables.AutoHatchEggId = nil;
end;
function AttemptHatch()
	local v2 = v1.StatService.Get();
	if not v2 then
		return;
	end;
	local l__AutoHatchEggId__3 = v1.Variables.AutoHatchEggId;
	if not l__AutoHatchEggId__3 then
		return;
	end;
	if v2.World ~= v1.Directory.Eggs[l__AutoHatchEggId__3].world then
		v1.Variables.AutoHatchEnabled = false;
		v1.Variables.AutoHatchEggId = nil;
		v1.Signal.Fire("Auto Hatch Updated");
		v1.Signal.Fire("Notification", "World Changed, Auto Hatch is now turned off", {
			color = Color3.fromRGB(255, 46, 46)
		});
		return;
	end;
	local v4, v5 = v1.Network.Invoke("Buy Egg", l__AutoHatchEggId__3, v2.AutoHatchSettings.TripleEggs);
	if not v4 then
		v1.Signal.Fire("Notification", "Failed to buy egg (" .. (v5 and "An error occurred") .. ")", {
			color = Color3.fromRGB(255, 46, 46)
		});
		if v2.AutoHatchSettings.StopOnFailure then
			v1.Variables.AutoHatchEnabled = false;
			v1.Variables.AutoHatchEggId = nil;
			v1.Signal.Fire("Auto Hatch Updated");
			v1.Signal.Fire("Notification", "Auto Hatch is now turned off", {
				color = Color3.fromRGB(255, 46, 46)
			});
		end;
	end;
end;
local l__ID__1 = v1.Directory.Gamepasses["Auto Hatch"].ID;
function CanPerform()
	if not v1.Gamepasses.Owns(l__ID__1) then
		return;
	end;
	if not v1.WorldCmds.CanDoAction() then
		return;
	end;
	return v1.Variables.AutoHatchEnabled;
end;
v1.Signal.Fired("Turn Auto Hatch"):Connect(function(p3, p4)
	TurnAutoHacth(p3, p4);
end);
task.defer(function()
	while true do
		if CanPerform() then
			wait(0.75);
			if CanPerform() then
				AttemptHatch();
			end;
		end;
		wait(v1.RunService.Heartbeat:Wait() * 5);	
	end;
end);

