local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Src.Resources.Constants);
local l_VoxelResolution_0 = v1.VoxelResolution;
local l_Util_0 = l_script_FirstAncestor_0.Src.Util;
local v4 = require(l_Util_0.AnalyticsHelper);
local v5 = require(l_Util_0.Operations.BaseOperation);
local v6 = require(l_Util_0.CalculateBrushOccupancy);
local v7 = require(l_Util_0.ClampVoxelBoundaries);
local v8 = require(l_Util_0.ConvertForPivot);
local v9 = require(l_Util_0.getDraggedPositions);
local v10 = require(l_Util_0.DEPRECATED_CalculateBrushPower);
local v11 = require(l_script_FirstAncestor_0.Src.Types);
local l_BrushShape_0 = v11.BrushShape;
local l_BrushSettings_0 = v11.BrushSettings;
local l_Category_0 = v11.Category;
local l_MaterialMode_0 = v11.MaterialMode;
local l_MaterialSettings_0 = v11.MaterialSettings;
local v17 = require(l_script_FirstAncestor_0.Src.Util.DebugFlags);
local v18 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorBrushPerformanceEnhancements);
local v19 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorTimeStatistic);
return function(v20, v21)
    return v5.new({
        Budget = 0.005,
        OnFinish = function(_, _)
            v21.ChangeHistoryService:SetWaypoint("Paint");
        end,
        OnStart = function(v24, _)
            local v26 = v24.Payload[l_Category_0.BrushSettings];
            local v27 = v26[l_BrushSettings_0.BrushSize];
            v24.State = {
                Position = v8(v26[l_BrushSettings_0.PivotPosition], v26[l_BrushSettings_0.State].Position, if v26[l_BrushSettings_0.BrushShape] == l_BrushShape_0.Sphere then v27.Size else v27.Height * v1.VoxelResolution)
            };
        end,
        OnStep = if not v18() then function(v28, v29)
            assert(v28.State, "Tried to step without starting first.");
            local l_State_0 = v28.State;
            local v31 = v28.Payload[l_Category_0.BrushSettings];
            local v32 = v31[l_BrushSettings_0.BrushSize];
            local l_Height_0 = v32.Height;
            local l_Size_0 = v32.Size;
            local v35 = v31[l_BrushSettings_0.BrushShape];
            local v36 = v31[l_BrushSettings_0.State];
            local v37 = v31[l_BrushSettings_0.IgnoreWater];
            local v38 = v28.Payload[l_Category_0.MaterialSettings];
            local v39 = v38[l_MaterialSettings_0.MaterialMode];
            local v40 = v38[l_MaterialSettings_0.SourceMaterial];
            local v41 = v38[l_MaterialSettings_0.TargetMaterial];
            local v42 = if v35 == l_BrushShape_0.Sphere then l_Size_0 else l_Height_0 * v1.VoxelResolution;
            local v43 = (l_Size_0 * v1.VoxelResolution) * 0.5;
            local v44 = v9(l_State_0.Position, v8(v31[l_BrushSettings_0.PivotPosition], v36.Position, v42), v43);
            l_State_0.Position = v44[#v44];
            for _, v46 in v44, nil, nil do
                local v47, v48 = v7(v46, v43, v42);
                local v49 = Region3.new(v47, v48);
                local v50 = (v48.X - v47.X) * 0.5;
                local v51, v52 = v21.Terrain:ReadVoxels(v49, v1.VoxelResolution);
                local v53 = nil;
                if v19() then
                    v53 = os.clock();
                end;
                v51.Size = nil;
                v52.Size = nil;
                local v54 = {};
                local v55 = {};
                local v56 = {};
                local v57 = {};
                for v58, v59 in v52, nil, nil do
                    local v60 = (v47.X + (v58 - 0.5) * v1.VoxelResolution) - v46.X;
                    v54[v58] = {};
                    v55[v58] = {};
                    v56[v58] = {};
                    v57[v58] = {};
                    for v61, v62 in v59, nil, nil do
                        local v63 = (v47.Y + (v61 - 0.5) * v1.VoxelResolution) - v46.Y;
                        v54[v58][v61] = {};
                        v55[v58][v61] = {};
                        v56[v58][v61] = {};
                        v57[v58][v61] = {};
                        for v64, v65 in v62, nil, nil do
                            local _ = Vector3.new(v58, v61, v64);
                            local v67 = v51[v58][v61][v64];
                            local v68, v69 = v10(Vector3.new(v60, v63, (v47.Z + (v64 - 0.5) * v1.VoxelResolution) - v46.Z), l_Size_0, v35, v50);
                            if l_Size_0 > 20 then
                                v69 = v69 * ((l_Size_0 - 20) / 5);
                            end;
                            v56[v58][v61][v64] = Enum.Material.Air;
                            v57[v58][v61][v64] = 0;
                            if v68 > 0 and (not v37 or v67 ~= Enum.Material.Water) then
                                if v39 == l_MaterialMode_0.Paint then
                                    v55[v58][v61][v64] = v65;
                                    v54[v58][v61][v64] = v40;
                                elseif v39 == l_MaterialMode_0.Replace then
                                    v55[v58][v61][v64] = v40 == Enum.Material.Air and 1 or v65;
                                    v54[v58][v61][v64] = if v40 == v67 then v41 else v67;
                                end;
                            else
                                v55[v58][v61][v64] = v65;
                                v54[v58][v61][v64] = v67;
                            end;
                        end;
                    end;
                end;
                if v19() then
                    v29:addTimeStatistic(v4.NormalizeBrushTimer(v53, l_Size_0, l_Height_0));
                end;
                if not (v40 ~= Enum.Material.Water) or v41 == Enum.Material.Water then
                    v21.Terrain:WriteVoxels(v49, v1.VoxelResolution, v56, v57);
                end;
                v21.Terrain:WriteVoxels(v49, v1.VoxelResolution, v54, v55);
            end;
            return true, 0;
        end else function(v70, v71)
            assert(v70.State, "Tried to step without starting first.");
            if v17.ProfileTools() then
                debug.profilebegin("Paint Operation");
            end;
            local _ = os.clock();
            local l_State_1 = v70.State;
            local v74 = v70.Payload[l_Category_0.BrushSettings];
            local v75 = v74[l_BrushSettings_0.BrushSize];
            local l_Height_1 = v75.Height;
            local l_Size_1 = v75.Size;
            local v78 = v74[l_BrushSettings_0.BrushShape];
            local v79 = v74[l_BrushSettings_0.State];
            local v80 = v74[l_BrushSettings_0.IgnoreWater];
            local v81 = v70.Payload[l_Category_0.MaterialSettings];
            local v82 = v81[l_MaterialSettings_0.MaterialMode];
            local v83 = v81[l_MaterialSettings_0.SourceMaterial];
            local v84 = v81[l_MaterialSettings_0.TargetMaterial];
            local v85 = if v78 == l_BrushShape_0.Sphere then l_Size_1 else l_Height_1 * l_VoxelResolution_0;
            local v86 = (l_Size_1 * l_VoxelResolution_0) * 0.5;
            local v87 = v9(l_State_1.Position, v8(v74[l_BrushSettings_0.PivotPosition], v79.Position, v85), v86);
            l_State_1.Position = v87[#v87];
            local v88 = v82 == l_MaterialMode_0.Paint;
            local v89 = v82 == l_MaterialMode_0.Replace;
            for _, v91 in v87, nil, nil do
                if v91 == l_State_1.LastPosition then
                    v71:skipBudget();
                    if v17.ProfileTools() then
                        debug.profileend();
                    end;
                    return true, 0;
                else
                    l_State_1.LastPosition = v91;
                    local v92, v93 = v7(v91, v86, v85);
                    local v94 = Region3.new(v92, v93);
                    if not (v78 == l_BrushShape_0.Cube) or not v89 then
                        local v95 = (v93.X - v92.X) * 0.5;
                        local v96, v97 = v21.Terrain:ReadVoxels(v94, l_VoxelResolution_0);
                        v96.Size = nil;
                        v97.Size = nil;
                        local l_l_VoxelResolution_0_0 = l_VoxelResolution_0;
                        local v99 = v83 == Enum.Material.Air;
                        local v100 = false;
                        if v78 == l_BrushShape_0.Sphere then
                            v100 = l_Size_1 > 2;
                        end;
                        local v101;
                        if v78 == l_BrushShape_0.Cylinder then
                            v101 = true;
                            if not (l_Size_1 <= 2) then
                                goto label0;
                            end;
                        end;
                        v101 = v100;
                        ::label0::;
                        local v102 = (v92.X - l_l_VoxelResolution_0_0 * 0.5) - v91.X;
                        local v103 = (v92.Y - l_l_VoxelResolution_0_0 * 0.5) - v91.Y;
                        local v104 = (v92.Z - l_l_VoxelResolution_0_0 * 0.5) - v91.Z;
                        local v105 = nil;
                        local v106 = nil;
                        local v107 = nil;
                        if v19() then
                            v107 = os.clock();
                        end;
                        for v108, v109 in v97, nil, nil do
                            v105 = if not v101 then nil else (v108 * l_l_VoxelResolution_0_0 + v102) ^ 2;
                            local v110 = v96[v108];
                            for v111, v112 in v109, nil, nil do
                                v106 = if not v100 then nil else v105 + (v111 * l_l_VoxelResolution_0_0 + v103) ^ 2;
                                local v113 = v110[v111];
                                for v114, v115 in v112, nil, nil do
                                    local v116 = v113[v114];
                                    local v117 = 1;
                                    if v101 then
                                        local v118 = (v114 * l_l_VoxelResolution_0_0 + v104) ^ 2;
                                        v117 = v6(if not v100 then math.sqrt(v105 + v118) else math.sqrt(v106 + v118), v95);
                                    end;
                                    if v117 > 0 and (not v80 or v116 ~= Enum.Material.Water) then
                                        if not v88 then
                                            if v89 then
                                                v112[v114] = if not v99 then v115 else 1;
                                                v113[v114] = if v83 == v116 then v84 else v116;
                                            end;
                                        else
                                            v112[v114] = v115;
                                            v113[v114] = v83;
                                        end;
                                    else
                                        v112[v114] = v115;
                                        v113[v114] = v116;
                                    end;
                                end;
                            end;
                        end;
                        if v19() then
                            v71:addTimeStatistic(v4.NormalizeBrushTimer(v107, l_Size_1, l_Height_1));
                        end;
                        if not (v83 ~= Enum.Material.Water) or v84 == Enum.Material.Water then
                            v21.Terrain:FillRegion(v94, v1.VoxelResolution, Enum.Material.Air);
                        end;
                        v21.Terrain:WriteVoxels(v94, v1.VoxelResolution, v96, v97);
                    else
                        v21.Terrain:ReplaceMaterial(v94, l_VoxelResolution_0, v83, v84);
                    end;
                end;
            end;
            if v17.ProfileTools() then
                debug.profileend();
            end;
            return true, 0;
        end,
        Name = v20
    });
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local l_Util_0 = l_script_FirstAncestor_0.Src.Util;
local v2 = require(l_Util_0.AnalyticsHelper);
local v3 = require(l_Util_0.CalculateAutoMaterial);
local v4 = require(l_Util_0.CalculateBrushOccupancy);
local v5 = require(l_Util_0.CalculateMagnitudePercent);
local v6 = require(l_Util_0.CalculateWaterLevel);
local v7 = require(l_Util_0.ClampVoxelBoundaries);
local v8 = require(l_Util_0.ConvertForPivot);
local v9 = require(l_Util_0.getDraggedPositions);
local v10 = require(l_Util_0.DEPRECATED_CalculateAutoMaterial);
local v11 = require(l_Util_0.DEPRECATED_CalculateBrushPower);
local v12 = require(l_script_FirstAncestor_0.Src.Resources.Constants);
local l_VoxelResolution_0 = v12.VoxelResolution;
local v14 = require(l_script_FirstAncestor_0.Src.Util.Operations.SmoothOperation);
local v15 = require(l_script_FirstAncestor_0.Src.Util.Operations.BaseOperation);
local v16 = require(l_script_FirstAncestor_0.Src.Types);
local l_BrushMode_0 = v16.BrushMode;
local l_BrushSettings_0 = v16.BrushSettings;
local l_BrushShape_0 = v16.BrushShape;
local l_Category_0 = v16.Category;
local l_MaterialSettings_0 = v16.MaterialSettings;
local v22 = require(l_script_FirstAncestor_0.Src.Util.DebugFlags);
local v23 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorWaterAutofill);
local v24 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorBrushPerformanceEnhancements);
local v25 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorTimeStatistic);
local v26 = v24();
local v27 = {
    Vector3.new(-1, 0, 0),
    Vector3.new(1, 0, 0),
    Vector3.new(0, -1, 0),
    Vector3.new(0, 1, 0),
    Vector3.new(0, 0, -1),
    (Vector3.new(0, 0, 1))
};
return function(v28, v29)
    return v15.new({
        Name = v28,
        OnFinish = function(v30, _)
            v29.ChangeHistoryService:SetWaypoint("Sculpt");
            assert(v30.State, "Tried to step without starting first.");
            if v30.State.Smooth then
                v30.State.Smooth:cancel();
            end;
        end,
        OnStart = function(v32, _)
            local v34 = v32.Payload[l_Category_0.BrushSettings];
            local v35 = v34[l_BrushSettings_0.BrushSize];
            v32.State = {
                Position = v8(v34[l_BrushSettings_0.PivotPosition], v34[l_BrushSettings_0.State].Position, if v34[l_BrushSettings_0.BrushShape] == l_BrushShape_0.Sphere then v35.Size else v35.Height * l_VoxelResolution_0)
            };
        end,
        OnStep = function(v36, v37)
            assert(v36.State, "Tried to step without starting first.");
            if not (not v26 or not v22.ProfileTools()) then
                debug.profilebegin("Sculpt");
            end;
            local l_State_0 = v36.State;
            local v39 = v36.Payload[l_Category_0.BrushSettings];
            local v40 = v39[l_BrushSettings_0.BrushSize];
            local l_Height_0 = v40.Height;
            local l_Size_0 = v40.Size;
            local v43 = v39[l_BrushSettings_0.BrushMode];
            local v44 = v39[l_BrushSettings_0.BrushShape];
            local v45 = v39[l_BrushSettings_0.IgnoreWater];
            local v46 = v39[l_BrushSettings_0.Strength];
            local v47 = if not v23() then nil else v39[l_BrushSettings_0.WaterAutofill];
            local v48 = v39[l_BrushSettings_0.State];
            local v49 = v39[l_BrushSettings_0.TemporarySmooth];
            local v50 = false;
            if v44 == l_BrushShape_0.Sphere then
                v50 = l_Size_0 > 2;
            end;
            local v51;
            if v44 == l_BrushShape_0.Cylinder then
                v51 = true;
                if not (l_Size_0 <= 2) then
                    goto label0;
                end;
            end;
            v51 = v50;
            ::label0::;
            if not v49 then
                if l_State_0.Smooth then
                    l_State_0.Smooth:cancel();
                    l_State_0.Smooth = nil;
                    l_State_0.Position = v48.Position;
                end;
                local v52 = v36.Payload[l_Category_0.MaterialSettings];
                local v53 = v52[l_MaterialSettings_0.AutoMaterial];
                local v54 = v52[l_MaterialSettings_0.SourceMaterial];
                local v55 = if v44 == l_BrushShape_0.Sphere then l_Size_0 else l_Height_0 * l_VoxelResolution_0;
                local v56 = (l_Size_0 * l_VoxelResolution_0) * 0.5;
                local v57 = Vector3.new(1, 0, 1);
                local v58 = v9(l_State_0.Position, v8(v39[l_BrushSettings_0.PivotPosition], v48.Position, v55), v56);
                l_State_0.Position = v58[#v58];
                for _, v60 in v58, nil, nil do
                    local v61, v62 = v7(v60, v56, v55);
                    local v63 = Region3.new(v61, v62);
                    local v64 = (v62.X - v61.X) * 0.5;
                    local v65 = {};
                    local v66, v67 = v29.Terrain:ReadVoxels(v63, l_VoxelResolution_0);
                    local v68, v69 = v29.Terrain:ReadVoxels(v63, l_VoxelResolution_0);
                    local v70 = nil;
                    local v71 = nil;
                    if v47 then
                        local v72, v73 = v29.Terrain:ReadVoxels(v63, l_VoxelResolution_0);
                        v70 = v72;
                        v71 = v73;
                    end;
                    local v74 = nil;
                    if v25() then
                        v74 = os.clock();
                    end;
                    v66.Size = nil;
                    v67.Size = nil;
                    local v75 = #v66;
                    local v76 = #v66[1];
                    local v77 = #v66[1][1];
                    local v78 = if not v26 then {} else table.create((v75 * v76) * v77, false);
                    local v79 = 0;
                    local v80 = Vector3.new(v75, v76, v77);
                    local v81 = nil;
                    local v82 = nil;
                    if v47 and v43 == l_BrushMode_0.Subtract then
                        local v83, v84 = v6(v66, v67);
                        v81 = v83;
                        v82 = v84;
                    end;
                    local v85 = Vector3.new(math.round((v60.X - v61.X) / l_VoxelResolution_0), math.round((v60.Y - v61.Y) / l_VoxelResolution_0), (math.round((v60.Z - v61.Z) / l_VoxelResolution_0)));
                    for v86 = -1, 1 do
                        for v87 = -1, 1 do
                            for v88 = -1, 1 do
                                local v89 = v85 + Vector3.new(v86, v87, v88);
                                local v90 = false;
                                if v89.X > 0 then
                                    v90 = v89.X <= v80.X;
                                end;
                                local v91 = false;
                                if v89.Y > 0 then
                                    v91 = v89.Y <= v80.Y;
                                end;
                                local v92 = false;
                                if v89.Z > 0 then
                                    v92 = v89.Z <= v80.Z;
                                end;
                                if not ((not v90 or not v91) or not v92) then
                                    v78[v89.X + v80.X * (v89.Y + v80.X * v89.Z)] = true;
                                    v79 = v79 + 1;
                                    table.insert(v65, v89);
                                end;
                            end;
                        end;
                    end;
                    do
                        local l_v70_0, l_v71_0, l_v79_0, l_v81_0, l_v82_0 = v70, v71, v79, v81, v82;
                        local function v120(v98, v99, v100, v101)
                            local v102 = 1;
                            local v103 = 1;
                            if not v26 then
                                local v104, v105 = v11(v99, l_Size_0, v44, v64);
                                v102 = v104;
                                v103 = v105;
                            elseif v51 then
                                local _ = if not v50 then (v99 * v57).Magnitude else v99.Magnitude;
                                v102 = v4(v99.Magnitude, v64);
                                v103 = v5(v99.Magnitude, v64);
                            end;
                            if not (v100 ~= 0) or v102 <= 0.5 then
                                return ;
                            else
                                local v107 = false;
                                local v108 = #v27;
                                for _, v110 in v27, nil, nil do
                                    local v111 = v98 + v110;
                                    local v112 = false;
                                    if v111.X > 0 then
                                        v112 = v111.X <= v80.X;
                                    end;
                                    local v113 = false;
                                    if v111.Y > 0 then
                                        v113 = v111.Y <= v80.Y;
                                    end;
                                    local v114 = false;
                                    if v111.Z > 0 then
                                        v114 = v111.Z <= v80.Z;
                                    end;
                                    if not ((not v112 or not v113) or not v114) then
                                        local v115 = v67[v111.X][v111.Y][v111.Z];
                                        local v116 = v66[v111.X][v111.Y][v111.Z];
                                        if v45 and v116 == Enum.Material.Water then
                                            v115 = 0;
                                        end;
                                        if v115 <= 0 then
                                            v107 = true;
                                        end;
                                        v108 = v108 - v115;
                                    end;
                                end;
                                local v117 = nil;
                                v117 = if not v26 then math.min(if not (v100 >= 1) or v107 then v100 - ((((v108 / #v27) * (v46 + 0.05)) * 0.05) * v102) * v103 else v100, v12.MaximumOccupancy) else math.min(if not (v100 >= 1) or v107 then v100 - ((((v108 / #v27) * (v46 + 0.05)) * (l_Size_0 / 256 + 0.01)) * v102) * v103 else v100, v12.MaximumOccupancy);
                                local v118 = if not not l_v81_0 and v98.Y <= l_v81_0 then Enum.Material.Water else Enum.Material.Air;
                                local v119 = if v98.Y == l_v81_0 then l_v82_0 else 1;
                                if v117 <= v12.MinimumOccupancy then
                                    if l_v81_0 and v98.Y <= l_v81_0 then
                                        l_v71_0[v98.X][v98.Y][v98.Z] = 0;
                                        l_v70_0[v98.X][v98.Y][v98.Z] = Enum.Material.Air;
                                    end;
                                    v69[v98.X][v98.Y][v98.Z] = v118 == Enum.Material.Water and v119 or 0;
                                    v68[v98.X][v98.Y][v98.Z] = v118;
                                    return ;
                                elseif l_v81_0 and v98.Y <= l_v81_0 then
                                    l_v71_0[v98.X][v98.Y][v98.Z] = v117;
                                    l_v70_0[v98.X][v98.Y][v98.Z] = v101;
                                    v69[v98.X][v98.Y][v98.Z] = v119;
                                    v68[v98.X][v98.Y][v98.Z] = v118;
                                    return ;
                                else
                                    v69[v98.X][v98.Y][v98.Z] = v117;
                                    return ;
                                end;
                            end;
                        end;
                        local function v143(v121, v122, v123, v124)
                            local v125 = 1;
                            local v126 = 1;
                            if not v26 then
                                local v127, v128 = v11(v122, l_Size_0, v44, v64);
                                v125 = v127;
                                v126 = v128;
                            elseif v51 then
                                local _ = if not v50 then (v122 * v57).Magnitude else v122.Magnitude;
                                v125 = v4(v122.Magnitude, v64);
                                v126 = v5(v122.Magnitude, v64);
                            end;
                            if not (v123 ~= 1) or v125 < 0.5 then
                                return ;
                            else
                                local v130 = false;
                                local v131 = #v27;
                                local v132 = 0;
                                for _, v134 in v27, nil, nil do
                                    local v135 = v121 + v134;
                                    local v136 = false;
                                    if v135.X > 0 then
                                        v136 = v135.X < v80.X;
                                    end;
                                    local v137 = false;
                                    if v135.Y > 0 then
                                        v137 = v135.Y < v80.Y;
                                    end;
                                    local v138 = false;
                                    if v135.Z > 0 then
                                        v138 = v135.Z < v80.Z;
                                    end;
                                    if not ((not v136 or not v137) or not v138) then
                                        local v139 = v67[v135.X][v135.Y][v135.Z];
                                        local v140 = v66[v135.X][v135.Y][v135.Z];
                                        if v45 and v140 == Enum.Material.Water then
                                            v139 = 0;
                                        end;
                                        if v139 >= 1 then
                                            v130 = true;
                                        end;
                                        v132 = v132 + 1;
                                        v131 = v131 + v139;
                                    end;
                                end;
                                v131 = v132 == 0 and 0 or v131 / v132;
                                local v141 = nil;
                                v141 = math.min(if not v26 then if not (v123 <= 0) or v130 then v123 + (((v131 * (v46 + 0.05)) * 0.05) * v125) * v126 else v123 else if not (v123 <= 0) or v130 then v123 + (((v131 * (v46 + 0.05)) * (l_Size_0 / 256 + 0.01)) * v125) * v126 else v123, v12.MaximumOccupancy);
                                if v124 == Enum.Material.Air and v141 > 0 then
                                    if not v26 then
                                        v68[v121.X][v121.Y][v121.Z] = if not v53 then v54 else v10(v66, v121, v80, v45);
                                    else
                                        local v142 = if not v53 then v54 else v3(v121.X, v121.Y, v121.Z, v66, v80);
                                        if v45 and v142 == Enum.Material.Water then
                                            v142 = Enum.Material.Air;
                                        end;
                                        v68[v121.X][v121.Y][v121.Z] = v142;
                                    end;
                                end;
                                if v141 ~= v123 then
                                    v69[v121.X][v121.Y][v121.Z] = v141;
                                end;
                                return ;
                            end;
                        end;
                        local function v158(v144)
                            local v145 = true;
                            local v146 = true;
                            local v147 = true;
                            for v148 = -1, 1 do
                                for v149 = -1, 1 do
                                    for v150 = -1, 1 do
                                        local v151 = v144 + Vector3.new(v148, v149, v150);
                                        local v152 = false;
                                        if v151.X > 0 then
                                            v152 = v151.X <= v80.X;
                                        end;
                                        local v153 = false;
                                        if v151.Y > 0 then
                                            v153 = v151.Y <= v80.Y;
                                        end;
                                        local v154 = false;
                                        if v151.Z > 0 then
                                            v154 = v151.Z <= v80.Z;
                                        end;
                                        if not ((not v152 or not v153) or not v154) and (not (v148 == 0 and v149 == 0) or v150 ~= 0) then
                                            local v155 = v66[v151.X][v151.Y][v151.Z];
                                            local v156 = v67[v151.X][v151.Y][v151.Z];
                                            local v157 = v66[v151.X][v151.Y][v151.Z] == Enum.Material.Water;
                                            if not (not v45 or not v157) then
                                                v156 = 0;
                                            end;
                                            if v156 > 0 then
                                                v145 = false;
                                            end;
                                            if v156 < 1 then
                                                v146 = false;
                                            end;
                                            if v155 ~= Enum.Material.Water then
                                                v147 = true;
                                            end;
                                            if not ((v146 or v145) or l_v81_0 and not v147) then
                                                return false, false;
                                            end;
                                        end;
                                    end;
                                end;
                            end;
                            return v145, v146, v147;
                        end;
                        local function v179(v159, v160)
                            local v161, v162, v163 = v158(v159);
                            local v164 = v67[v159.X][v159.Y][v159.Z];
                            local v165;
                            if v43 == l_BrushMode_0.Add then
                                v165 = v162 or (not (v164 ~= 0) or v160) and v161;
                            else
                                v165 = v161;
                                if not v165 then
                                    v165 = false;
                                    if v164 == 1 then
                                        v165 = not v160 and v162;
                                    end;
                                end;
                            end;
                            local v166 = false;
                            if v43 == l_BrushMode_0.Subtract then
                                v166 = l_v81_0 and v163;
                            end;
                            if not (v165 and not v166) then
                                for v167 = -1, 1 do
                                    for v168 = -1, 1 do
                                        for v169 = -1, 1 do
                                            local v170 = v159 + Vector3.new(v167, v168, v169);
                                            local v171 = false;
                                            if v170.X > 0 then
                                                v171 = v170.X <= v80.X;
                                            end;
                                            local v172 = false;
                                            if v170.Y > 0 then
                                                v172 = v170.Y <= v80.Y;
                                            end;
                                            local v173 = false;
                                            if v170.Z > 0 then
                                                v173 = v170.Z <= v80.Z;
                                            end;
                                            if not ((not v171 or not v172) or not v173) and (not (v167 == 0 and v168 == 0) or v169 ~= 0) then
                                                local v174 = v67[v170.X][v170.Y][v170.Z];
                                                local v175 = v66[v170.X][v170.Y][v170.Z];
                                                if if not v26 then v45 and v66[v170.X][v170.Y][v170.Z] == Enum.Material.Water else v45 and v175 == Enum.Material.Water then
                                                    v174 = 0;
                                                end;
                                                local v176 = false;
                                                local v177 = false;
                                                local v178 = if not v26 then l_v81_0 and v66[v170.X][v170.Y][v170.Z] == Enum.Material.Water else l_v81_0 and v175 == Enum.Material.Water;
                                                if v43 == l_BrushMode_0.Add then
                                                    v177 = v174 < 1;
                                                    if not (v164 ~= 0 and not v160) and v174 == 0 then
                                                        v177 = false;
                                                    end;
                                                elseif v43 == l_BrushMode_0.Subtract then
                                                    v176 = v174 > 0;
                                                    if not (not (v164 == 1) or v160) and v174 == 1 then
                                                        v176 = false;
                                                    end;
                                                end;
                                                if not (not (v177 or v176) and not v178 or v78[v170.X + v80.X * (v170.Y + v80.X * v170.Z)]) then
                                                    v78[v170.X + v80.X * (v170.Y + v80.X * v170.Z)] = true;
                                                    l_v79_0 = l_v79_0 + 1;
                                                    table.insert(v65, v170);
                                                end;
                                            end;
                                        end;
                                    end;
                                end;
                            end;
                        end;
                        while #v65 > 0 do
                            local v180 = table.remove(v65);
                            local v181 = v67[v180.X][v180.Y][v180.Z];
                            local v182 = v66[v180.X][v180.Y][v180.Z];
                            local v183;
                            if v45 then
                                v183 = true;
                                if not (v182 ~= Enum.Material.Water) then
                                    goto label1;
                                end;
                            end;
                            v183 = v182 == Enum.Material.Air;
                            ::label1::;
                            local v184 = (v61 + (v180 - Vector3.new(0.5, 0.5, 0.5)) * l_VoxelResolution_0) - v60;
                            if l_v81_0 and v182 == Enum.Material.Water then
                                v179(v180, v183);
                            else
                                if not (v43 == l_BrushMode_0.Subtract and v181 > 0) or v183 then
                                    if not (not (v43 == l_BrushMode_0.Add) or v181 >= 1 and not v183) then
                                        if v45 and v182 == Enum.Material.Water then
                                            v182 = Enum.Material.Air;
                                            v181 = 0;
                                        end;
                                        v143(v180, v184, v181, v182);
                                    end;
                                else
                                    if v45 and v182 == Enum.Material.Water then
                                        v181 = 0;
                                    end;
                                    v120(v180, v184, v181, v182);
                                end;
                                v179(v180, v183);
                            end;
                        end;
                        if v25() then
                            v37:addTimeStatistic(v2.NormalizeDepthFirstSearch(v74, l_v79_0));
                        end;
                        if l_v81_0 then
                            v29.Terrain:WriteVoxels(v63, l_VoxelResolution_0, l_v70_0, l_v71_0);
                        end;
                        v29.Terrain:WriteVoxels(v63, l_VoxelResolution_0, v68, v69);
                    end;
                end;
                if not (not v26 or not v22.ProfileTools()) then
                    debug.profileend();
                end;
                return true, 0;
            else
                if l_State_0.Smooth then
                    l_State_0.Smooth:updatePayload(v36.Payload);
                else
                    local v185 = v14("Smooth", v29);
                    v185:start({
                        Payload = v36.Payload
                    });
                    l_State_0.Smooth = v185;
                end;
                return true, 0;
            end;
        end
    });
end;


local v0 = require(script:FindFirstAncestor("TerrainEditor").Src.Util.Operations.BaseOperation);
return function(v1, v2, v3, v4)
    return v0.new({
        AllowCancel = true,
        Description = v2,
        Name = v1,
        OnCancel = function()
            v3.ShorelineUpgraderService:Cancel();
            v4(v3.Terrain and v3.Terrain:CanShorelinesBeUpgraded());
        end,
        OnFinish = function()
            v3.ChangeHistoryService:SetWaypoint("Upgrade Shorelines");
            v4(v3.Terrain and v3.Terrain:CanShorelinesBeUpgraded());
        end,
        OnStart = function(v5, _)
            v3.ShorelineUpgraderService:Start();
            v3.ShorelineUpgraderService.Status:Connect(function(v7)
                assert(v5.State, "Tried to update the state without it existing.");
                v5.State.Percent = v7;
            end);
            v5.State = {
                Percent = 0
            };
        end,
        OnStep = function(v8, _)
            assert(v8.State, "Tried to step without starting first.");
            local l_State_0 = v8.State;
            v4(v3.Terrain and v3.Terrain:CanShorelinesBeUpgraded());
            return l_State_0.Percent < 1, l_State_0.Percent;
        end
    });
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Src.Resources.Constants);
local l_VoxelResolution_0 = v1.VoxelResolution;
local l_Util_0 = l_script_FirstAncestor_0.Src.Util;
local v4 = require(l_Util_0.AnalyticsHelper);
local v5 = require(l_Util_0.Operations.BaseOperation);
local v6 = require(l_Util_0.CalculateBrushOccupancy);
local v7 = require(l_Util_0.CalculateMagnitudePercent);
local v8 = require(l_Util_0.ClampVoxelBoundaries);
local v9 = require(l_Util_0.ConvertForPivot);
local v10 = require(l_Util_0.getDraggedPositions);
local v11 = require(l_Util_0.DEPRECATED_CalculateBrushPower);
local v12 = require(l_script_FirstAncestor_0.Src.Types);
local l_BrushShape_0 = v12.BrushShape;
local l_BrushSettings_0 = v12.BrushSettings;
local l_Category_0 = v12.Category;
local v16 = require(l_script_FirstAncestor_0.Src.Util.DebugFlags);
local v17 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorBrushPerformanceEnhancements);
local v18 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorTimeStatistic);
return function(v19, v20)
    return v5.new({
        Budget = 0.005,
        OnFinish = function(_, _)
            v20.ChangeHistoryService:SetWaypoint("Smooth");
        end,
        OnStart = function(v23, _)
            local v25 = v23.Payload[l_Category_0.BrushSettings];
            local v26 = v25[l_BrushSettings_0.BrushSize];
            v23.State = {
                Position = v9(v25[l_BrushSettings_0.PivotPosition], v25[l_BrushSettings_0.State].Position, if v25[l_BrushSettings_0.BrushShape] == l_BrushShape_0.Sphere then v26.Size else v26.Height * l_VoxelResolution_0)
            };
        end,
        OnStep = if not v17() then function(v27, v28)
            assert(v27.State, "Tried to step without starting first.");
            local l_State_0 = v27.State;
            local v30 = v27.Payload[l_Category_0.BrushSettings];
            local v31 = v30[l_BrushSettings_0.BrushSize];
            local l_Height_0 = v31.Height;
            local l_Size_0 = v31.Size;
            local v34 = v30[l_BrushSettings_0.BrushShape];
            local v35 = v30[l_BrushSettings_0.State];
            local v36 = v30[l_BrushSettings_0.IgnoreWater];
            local v37 = v30[l_BrushSettings_0.Strength] or 1;
            local v38 = if v34 == l_BrushShape_0.Sphere then l_Size_0 else l_Height_0 * v1.VoxelResolution;
            local v39 = (l_Size_0 * v1.VoxelResolution) * 0.5;
            local v40 = v10(l_State_0.Position, v9(v30[l_BrushSettings_0.PivotPosition], v35.Position, v38), v39);
            l_State_0.Position = v40[#v40];
            for _, v42 in v40, nil, nil do
                local v43, v44 = v8(v42, v39, v38);
                local v45 = Region3.new(v43, v44);
                local v46 = (v44.X - v43.X) * 0.5;
                local v47, v48 = v20.Terrain:ReadVoxels(v45, v1.VoxelResolution);
                v47.Size = nil;
                v48.Size = nil;
                local v49, v50 = v20.Terrain:SmoothRegion(v45, v1.VoxelResolution, v37);
                local v51 = nil;
                if v18() then
                    v51 = os.clock();
                end;
                local function v59(v52, v53)
                    local v54, v55 = v11(v53, l_Size_0, v34, v46);
                    if v36 and v47[v52.X][v52.Y][v52.Z] == Enum.Material.Water then
                        v50[v52.X][v52.Y][v52.Z] = v48[v52.X][v52.Y][v52.Z];
                        v49[v52.X][v52.Y][v52.Z] = v47[v52.X][v52.Y][v52.Z];
                        return ;
                    else
                        local v56 = v49[v52.X][v52.Y][v52.Z];
                        local v57 = true;
                        if v56 ~= Enum.Material.Air then
                            v57 = v50[v52.X][v52.Y][v52.Z] <= 0;
                        end;
                        local v58 = math.clamp(v48[v52.X][v52.Y][v52.Z] + (((v50[v52.X][v52.Y][v52.Z] - v48[v52.X][v52.Y][v52.Z]) * v37) * v54) * v55, 0, 1);
                        if v58 ~= v50[v52.X][v52.Y][v52.Z] then
                            v50[v52.X][v52.Y][v52.Z] = v58;
                            if v57 and v1.MinimumSmooth <= v58 then
                                v49[v52.X][v52.Y][v52.Z] = v47[v52.X][v52.Y][v52.Z];
                                return ;
                            elseif v58 <= 0 then
                                v49[v52.X][v52.Y][v52.Z] = Enum.Material.Air;
                            end;
                        end;
                        return ;
                    end;
                end;
                v47.Size = nil;
                v48.Size = nil;
                for v60, v61 in v48, nil, nil do
                    local v62 = (v43.X + (v60 - 0.5) * v1.VoxelResolution) - v42.X;
                    for v63, v64 in v61, nil, nil do
                        local v65 = (v43.Y + (v63 - 0.5) * v1.VoxelResolution) - v42.Y;
                        for v66, _ in v64, nil, nil do
                            local v68 = Vector3.new(v60, v63, v66);
                            v59(v68, (Vector3.new(v62, v65, (v43.Z + (v68.Z - 0.5) * v1.VoxelResolution) - v42.Z)));
                        end;
                    end;
                end;
                if v18() then
                    v28:addTimeStatistic(v4.NormalizeBrushTimer(v51, l_Size_0, l_Height_0));
                end;
                v20.Terrain:WriteVoxels(v45, v1.VoxelResolution, v49, v50);
            end;
            return true, 0;
        end else function(v69, v70)
            assert(v69.State, "Tried to step without starting first.");
            if v16.ProfileTools() then
                debug.profilebegin("Smooth");
            end;
            local l_State_1 = v69.State;
            local v72 = v69.Payload[l_Category_0.BrushSettings];
            local v73 = v72[l_BrushSettings_0.BrushSize];
            local l_Height_1 = v73.Height;
            local l_Size_1 = v73.Size;
            local v76 = v72[l_BrushSettings_0.BrushShape];
            local v77 = v72[l_BrushSettings_0.State];
            local v78 = v72[l_BrushSettings_0.IgnoreWater];
            local v79 = v72[l_BrushSettings_0.Strength] or 1;
            local v80 = false;
            if v76 == l_BrushShape_0.Sphere then
                v80 = l_Size_1 > 2;
            end;
            local v81;
            if v76 == l_BrushShape_0.Cylinder then
                v81 = true;
                if not (l_Size_1 <= 2) then
                    goto label0;
                end;
            end;
            v81 = v80;
            ::label0::;
            local v82 = if v76 == l_BrushShape_0.Sphere then l_Size_1 else l_Height_1 * l_VoxelResolution_0;
            local v83 = (l_Size_1 * l_VoxelResolution_0) * 0.5;
            local v84 = v10(l_State_1.Position, v9(v72[l_BrushSettings_0.PivotPosition], v77.Position, v82), v83);
            l_State_1.Position = v84[#v84];
            for _, v86 in v84, nil, nil do
                local v87, v88 = v8(v86, v83, v82);
                local v89 = Region3.new(v87, v88);
                local v90 = (v88.X - v87.X) * 0.5;
                local v91 = (v87.X - l_VoxelResolution_0 * 0.5) - v86.X;
                local v92 = (v87.Y - l_VoxelResolution_0 * 0.5) - v86.Y;
                local v93 = (v87.Z - l_VoxelResolution_0 * 0.5) - v86.Z;
                local v94 = nil;
                local v95 = nil;
                local v96, v97 = v20.Terrain:ReadVoxels(v89, l_VoxelResolution_0);
                local v98, v99 = v20.Terrain:SmoothRegion(v89, l_VoxelResolution_0, v79);
                v96.Size = nil;
                v97.Size = nil;
                local v100 = nil;
                if v18() then
                    v100 = os.clock();
                end;
                for v101, v102 in v97, nil, nil do
                    v94 = if not v81 then nil else (v101 * l_VoxelResolution_0 + v91) ^ 2;
                    local v103 = v98[v101];
                    local v104 = v99[v101];
                    local v105 = v96[v101];
                    for v106, v107 in v102, nil, nil do
                        v95 = if not v80 then nil else v94 + (v106 * l_VoxelResolution_0 + v92) ^ 2;
                        local v108 = v103[v106];
                        local v109 = v104[v106];
                        local v110 = v105[v106];
                        for v111, v112 in v107, nil, nil do
                            local v113 = v110[v111];
                            local v114 = 1;
                            local v115 = 1;
                            if v81 then
                                local v116 = (v111 * l_VoxelResolution_0 + v93) ^ 2;
                                local v117 = if not v80 then math.sqrt(v94 + v116) else math.sqrt(v95 + v116);
                                v114 = v6(v117, v90);
                                v115 = v7(v117, v90);
                            end;
                            if v78 and v113 == Enum.Material.Water then
                                v104[v111] = v112;
                                v108[v111] = v113;
                                return ;
                            else
                                local v118 = v108[v111];
                                local v119 = true;
                                if v118 ~= Enum.Material.Air then
                                    v119 = v109[v111] <= 0;
                                end;
                                local v120 = math.clamp(v112 + (((v109[v111] - v112) * v79) * v114) * v115, 0, 1);
                                if v120 ~= v109[v111] then
                                    v109[v111] = v120;
                                    if v119 and v1.MinimumSmooth <= v120 then
                                        v108[v111] = v113;
                                    elseif v120 <= 0 then
                                        v108[v111] = Enum.Material.Air;
                                    end;
                                end;
                            end;
                        end;
                    end;
                end;
                if v18() then
                    v70:addTimeStatistic(v4.NormalizeBrushTimer(v100, l_Size_1, l_Height_1));
                end;
                v20.Terrain:WriteVoxels(v89, l_VoxelResolution_0, v98, v99);
            end;
            if v16.ProfileTools() then
                debug.profileend();
            end;
            return true, 0;
        end,
        Name = v19
    });
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Src.Util.Operations.BaseOperation);
local l_Util_0 = l_script_FirstAncestor_0.Src.Util;
local v3 = require(l_Util_0.AnalyticsHelper);
local v4 = require(l_Util_0.ConvertTransformToRegion);
local v5 = require(l_Util_0.CreateSubregions);
local v6 = require(l_script_FirstAncestor_0.Src.Types);
local l_Category_0 = v6.Category;
local l_SelectionSettings_0 = v6.SelectionSettings;
local l_TransformMode_0 = v6.TransformMode;
local l_TransformSettings_0 = v6.TransformSettings;
local v11 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorTimeStatistic);
return function(v12, v13, v14)
    return v1.new({
        AllowPause = true,
        AllowCancel = true,
        Description = v13,
        Name = v12,
        OnCancel = function(v15, _)
            assert(v15.State, "Tried to cancel without starting first.");
            local l_State_0 = v15.State;
            v14.Terrain:PasteRegion(l_State_0.BackupTerrainRegion, l_State_0.BackupRegion.Min, true);
        end,
        OnFinish = function(v18, v19)
            if v11() then
                v19:addTimeStatistic(v3.NormalizeRegionTimer(v18.State.StartTime, v18.Payload[l_Category_0.TransformSettings][l_SelectionSettings_0.Size]));
            end;
            v14.ChangeHistoryService:SetWaypoint("TransformAction");
        end,
        OnStart = function(v20, _)
            local l_Terrain_0 = v14.Terrain;
            local v23 = v20.Payload[l_Category_0.SelectionSettings];
            local v24 = v20.Payload[l_Category_0.TransformSettings];
            local v25 = v23[l_SelectionSettings_0.Transform];
            local v26 = v23[l_SelectionSettings_0.Size];
            local v27 = nil;
            local v28 = nil;
            if v24[l_TransformSettings_0.TransformMode] == l_TransformMode_0.Move then
                v27 = v5(v25, v26);
                v28 = 1;
            end;
            local v29 = v24[l_TransformSettings_0.Transform];
            local v30 = v24[l_TransformSettings_0.Size];
            local v31, v32 = v5(v29, v30);
            local v33 = nil;
            v33 = if v24[l_TransformSettings_0.TransformMode] == l_TransformMode_0.Paste then v24[l_TransformSettings_0.TerrainRegionBuffer] else v24[l_TransformSettings_0.TerrainRegion];
            local v34 = v4(v29, v30);
            v20.State = {
                BackupRegion = v34,
                BackupTerrainRegion = l_Terrain_0:CopyRegion(v34),
                SourceCurrentIndex = v28,
                SourceRegions = v27,
                SourceTerrainRegion = v33,
                StartTime = os.clock(),
                TargetCurrentIndex = 1,
                TargetOrigins = v32,
                TargetRegions = v31
            };
        end,
        OnStep = function(v35, _)
            assert(v35.State, "Tried to step without starting first.");
            local l_State_1 = v35.State;
            local v38 = v35.Payload[l_Category_0.SelectionSettings];
            local v39 = v35.Payload[l_Category_0.TransformSettings];
            local l_SourceTerrainRegion_0 = l_State_1.SourceTerrainRegion;
            local l_Terrain_1 = v14.Terrain;
            local v42 = l_State_1.TargetOrigins[l_State_1.TargetCurrentIndex];
            local v43 = l_State_1.TargetRegions[l_State_1.TargetCurrentIndex];
            local v44 = v39[l_TransformSettings_0.Size];
            local v45 = v39[l_TransformSettings_0.Transform];
            if not ((not (v39[l_TransformSettings_0.TransformMode] == l_TransformMode_0.Move) or not l_State_1.SourceRegions) or not l_State_1.SourceCurrentIndex) then
                l_Terrain_1:SetMaterialInTransformSubregion(v38[l_SelectionSettings_0.Transform], v38[l_SelectionSettings_0.Size], Enum.Material.Air, l_State_1.SourceRegions[l_State_1.SourceCurrentIndex]);
                if l_State_1.SourceCurrentIndex ~= #l_State_1.SourceRegions then
                    l_State_1.SourceCurrentIndex = l_State_1.SourceCurrentIndex + 1;
                    return true, l_State_1.SourceCurrentIndex / (#l_State_1.SourceRegions + #l_State_1.TargetRegions);
                end;
            end;
            if v39[l_TransformSettings_0.MergeEmpty] then
                l_Terrain_1:SetMaterialInTransformSubregion(v45, v44, Enum.Material.Air, v43);
            end;
            l_Terrain_1:PasteRegion(l_SourceTerrainRegion_0:ApplyTransformSubregion(v45.Rotation, v44, v43), v42, false);
            if l_State_1.TargetCurrentIndex == #l_State_1.TargetRegions then
                return false, 0;
            else
                l_State_1.TargetCurrentIndex = l_State_1.TargetCurrentIndex + 1;
                return true, (l_State_1.TargetCurrentIndex + (l_State_1.SourceCurrentIndex or 0)) / (#l_State_1.TargetRegions + (not l_State_1.SourceRegions and 0 or #l_State_1.SourceRegions));
            end;
        end
    });
end;


local v0 = require(script:FindFirstAncestor("TerrainEditor").Src.Flags.getFFlagTerrainEditorGenerationFeature);
local function v10(v1)
    local v2 = {};
    local function v3(v4)
        local v5 = {};
        for v6, v7 in v4, nil, nil do
            if typeof(v7) == "table" and v7.serializedType then
                if v7.serializedType == "CFrame" then
                    v5[v6] = CFrame.fromMatrix(Vector3.new(v7.x, v7.y, v7.z), Vector3.new(v7.r00, v7.r10, v7.r20), Vector3.new(v7.r01, v7.r11, v7.r21), (Vector3.new(v7.r02, v7.r12, v7.r22)));
                elseif v7.serializedType == "Vector3" then
                    v5[v6] = Vector3.new(v7.x, v7.y, v7.z);
                elseif v7.serializedType == "Vector2" then
                    v5[v6] = Vector2.new(v7.x, v7.y);
                elseif v7.serializedType == "Material" then
                    v5[v6] = Enum.Material[v7.name];
                elseif v7.serializedType == "table" then
                    v5[v6] = v3(v7.value);
                elseif v7.serializedType then
                    error((("Undefined serialized type %*"):format(v7.serializedType)));
                end;
            else
                v5[v6] = v7;
            end;
        end;
        return v5;
    end;
    for v8, v9 in v1, nil, nil do
        v2[v8] = v3(v9);
    end;
    return v2;
end;
local function v17(v11)
    local v12 = {};
    for v13, v14 in v11, nil, nil do
        v12[v13] = {};
        for v15, v16 in v14, nil, nil do
            if typeof(v16) == "table" and v16.serializedType then
                if v16.serializedType == "CFrame" then
                    v12[v13][v15] = CFrame.fromMatrix(Vector3.new(v16.x, v16.y, v16.z), Vector3.new(v16.r00, v16.r10, v16.r20), Vector3.new(v16.r01, v16.r11, v16.r21), (Vector3.new(v16.r02, v16.r12, v16.r22)));
                elseif v16.serializedType == "Vector3" then
                    v12[v13][v15] = Vector3.new(v16.x, v16.y, v16.z);
                elseif v16.serializedType == "Material" then
                    v12[v13][v15] = Enum.Material[v16.name];
                elseif v16.serializedType then
                end;
            else
                v12[v13][v15] = v16;
            end;
        end;
    end;
    return v12;
end;
if not v0() then
    return v17;
else
    return v10;
end;


local v0 = require(script:FindFirstAncestor("TerrainEditor").Src.Flags.getFFlagTerrainEditorGenerationFeature);
local function v14(v1)
    local v2 = {};
    local function v3(v4)
        local v5 = {};
        for v6, v7 in v4, nil, nil do
            if typeof(v7) == "CFrame" then
                local l_Position_0 = v7.Position;
                local l_XVector_0 = v7.XVector;
                local l_YVector_0 = v7.YVector;
                local l_ZVector_0 = v7.ZVector;
                v5[v6] = {
                    x = l_Position_0.X,
                    y = l_Position_0.Y,
                    z = l_Position_0.Z,
                    r00 = l_XVector_0.X,
                    r10 = l_XVector_0.Y,
                    r20 = l_XVector_0.Z,
                    r01 = l_YVector_0.X,
                    r11 = l_YVector_0.Y,
                    r21 = l_YVector_0.Z,
                    r02 = l_ZVector_0.X,
                    r12 = l_ZVector_0.Y,
                    r22 = l_ZVector_0.Z,
                    serializedType = "CFrame"
                };
            elseif typeof(v7) == "Vector3" then
                v5[v6] = {
                    x = v7.X,
                    y = v7.Y,
                    z = v7.Z,
                    serializedType = "Vector3"
                };
            elseif typeof(v7) == "Vector2" then
                v5[v6] = {
                    x = v7.X,
                    y = v7.Y,
                    serializedType = "Vector2"
                };
            elseif typeof(v7) == "EnumItem" then
                v5[v6] = {
                    name = v7.Name,
                    serializedType = tostring(v7.EnumType)
                };
            elseif typeof(v7) == "table" then
                v5[v6] = {
                    value = v3(v7),
                    serializedType = "table"
                };
            elseif not (typeof(v7) == "Instance") then
                v5[v6] = v7;
            end;
        end;
        return v5;
    end;
    for v12, v13 in v1, nil, nil do
        v2[v12] = v3(v13);
    end;
    return v2;
end;
local function v25(v15)
    local v16 = {};
    for v17, v18 in v15, nil, nil do
        v16[v17] = {};
        for v19, v20 in v18, nil, nil do
            if typeof(v20) == "CFrame" then
                local l_Position_1 = v20.Position;
                local l_XVector_1 = v20.XVector;
                local l_YVector_1 = v20.YVector;
                local l_ZVector_1 = v20.ZVector;
                v16[v17][v19] = {
                    x = l_Position_1.X,
                    y = l_Position_1.Y,
                    z = l_Position_1.Z,
                    r00 = l_XVector_1.X,
                    r10 = l_XVector_1.Y,
                    r20 = l_XVector_1.Z,
                    r01 = l_YVector_1.X,
                    r11 = l_YVector_1.Y,
                    r21 = l_YVector_1.Z,
                    r02 = l_ZVector_1.X,
                    r12 = l_ZVector_1.Y,
                    r22 = l_ZVector_1.Z,
                    serializedType = "CFrame"
                };
            elseif typeof(v20) == "Vector3" then
                v16[v17][v19] = {
                    x = v20.X,
                    y = v20.Y,
                    z = v20.Z,
                    serializedType = "Vector3"
                };
            elseif typeof(v20) == "EnumItem" then
                v16[v17][v19] = {
                    name = v20.Name,
                    serializedType = tostring(v20.EnumType)
                };
            else
                v16[v17][v19] = v20;
            end;
        end;
    end;
    return v16;
end;
if not v0() then
    return v25;
else
    return v14;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local l_Storage_0 = require(l_script_FirstAncestor_0.Src.Types).Storage;
local v2 = require(l_script_FirstAncestor_0.Src.Schemas.Settings);
return {
    Get = function(v3, v4, v5, v6)
        local v7 = {};
        for v8, v9 in v2[v3].Storage, nil, nil do
            if v9 == l_Storage_0.Global then
                v7[v8] = v4:getGlobal(v3, v8);
            elseif v9 == l_Storage_0.LocalPersistent then
                v7[v8] = v5[v8];
            elseif not (not (v9 == l_Storage_0.LocalSession) or not v6) then
                v7[v8] = v6[v8];
            end;
        end;
        return v7;
    end,
    Set = function(v10, v11, v12)
        local v13 = {};
        local v14 = {};
        for v15, v16 in v2[v10].Storage, nil, nil do
            if v12[v15] ~= nil then
                if v16 == l_Storage_0.Global then
                    v11:setGlobal(v10, v15, v12[v15]);
                elseif v16 == l_Storage_0.LocalPersistent then
                    v13[v15] = v12[v15];
                elseif v16 == l_Storage_0.LocalSession then
                    v14[v15] = v12[v15];
                end;
            end;
        end;
        return v13, v14;
    end
};


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Src.Resources.Constants);
local v2 = require(l_script_FirstAncestor_0.Src.Types);
local v3 = {};
v3.Place = function(v4, v5, v6, v7)
    if not (v7 ~= v2.TerrainType.Volcano and v7 ~= v2.TerrainType.Mountain) or v7 == v2.TerrainType.Mesa then
        return v3.EmptyThreshold(v4, v5);
    elseif not (v7 ~= v2.TerrainType.Crater) or v7 == v2.TerrainType.Lake then
        return v3.OccupiedThreshold(v4, v5);
    else
        return v3.SurfaceThreshold(v4, v5, v6);
    end;
end;
v3.EmptyThreshold = function(v8, v9)
    local v10 = Region3.new((v8.Position - v9 / 2) - Vector3.new(0, v1.PlacementSnap * v1.VoxelResolution, 0), v8.Position + Vector3.new(v9.X, -v9.Y, v9.Z) / 2);
    local l_Terrain_0 = game:GetService("Workspace").Terrain;
    assert(l_Terrain_0, "Terrain should exist");
    local v12, v13 = l_Terrain_0:ReadVoxels(v10, 4);
    local v14 = #v12;
    local v15 = #v12[1];
    local v16 = #v12[1][1];
    for v17 = v15, 1, -1 do
        local v18 = false;
        for v19 = 1, v14 do
            for v20 = 1, v16 do
                if v13[v19][v17][v20] == 0 and v12[v19][v17][v20] == Enum.Material.Air then
                    v18 = true;
                end;
            end;
        end;
        if not v18 then
            return v8 + Vector3.new(0, v15 - v17, 0) * v1.VoxelResolution;
        end;
    end;
    return v8;
end;
v3.OccupiedThreshold = function(v21, v22)
    local v23 = Region3.new(v21.Position + Vector3.new(-v22.X, v22.Y, -v22.Z) / 2, (v21.Position + v22 / 2) + Vector3.new(0, v1.PlacementSnap * v1.VoxelResolution, 0));
    local l_Terrain_1 = game:GetService("Workspace").Terrain;
    assert(l_Terrain_1, "Terrain should exist");
    local v25, v26 = l_Terrain_1:ReadVoxels(v23, 4);
    local v27 = #v25;
    local v28 = #v25[1];
    local v29 = #v25[1][1];
    for v30 = 1, v28 do
        local v31 = false;
        for v32 = 1, v27 do
            for v33 = 1, v29 do
                if v26[v32][v30][v33] ~= 0 and v25[v32][v30][v33] ~= Enum.Material.Air then
                    v31 = true;
                end;
            end;
        end;
        if not v31 then
            return v21 + Vector3.new(0, v30 - 1, 0) * v1.VoxelResolution;
        end;
    end;
    return v21;
end;
v3.SurfaceThreshold = function(v34, v35, v36)
    return v34 + Vector3.new(0, -(v35.Y / 2) + math.floor(((v35.Y * v36) * 0.5) / v1.VoxelResolution) * v1.VoxelResolution, 0);
end;
return v3;


local v0 = require(script:FindFirstAncestor("TerrainEditor").Src.Types);
local l_BuildSettings_0 = v0.BuildSettings;
local l_HeightmapSettings_0 = v0.HeightmapSettings;
local v3 = {
    [l_BuildSettings_0.Material] = true,
    [l_HeightmapSettings_0.Heightmap] = true,
    [l_HeightmapSettings_0.Colormap] = true
};
local function v4(v5, v6)
    local v7 = {};
    for v8, v9 in pairs(v5) do
        if typeof(v9) == "table" then
            if v6[v8] and typeof(v6[v8]) == "table" then
                if not v3[v8] then
                    v7[v8] = v4(v9, v6[v8]);
                else
                    v7[v8] = v4(v6[v8], {});
                end;
            else
                v7[v8] = v4(v9, {});
            end;
        else
            v7[v8] = v9;
        end;
    end;
    for v10, v11 in pairs(v6) do
        if typeof(v11) == "table" then
            if not v5[v10] then
                v7[v10] = v4(v11, {});
            end;
        else
            v7[v10] = v11;
        end;
    end;
    return v7;
end;
return v4;


return function(v0, v1)
    local v2 = 4;
    local v3 = 16384;
    local v4 = v3 - v2;
    while v4 > 8 do
        local v5 = (v3 + v2) / 2;
        if ((v0.X + v5) * (v0.Y + v5)) * (v0.Z + v5) < v1 then
            v2 = v5;
        else
            v3 = v5;
        end;
        v4 = v3 - v2;
    end;
    local v6 = math.floor(v2 / 4) * 4;
    return v0 + Vector3.new(v6, v6, v6);
end;


return function(v0, v1, v2)
    local v3 = {
        Vector3.new(v1.X / 2, v1.Y / 2, v1.Z / 2),
        Vector3.new(-v1.X / 2, v1.Y / 2, v1.Z / 2),
        Vector3.new(v1.X / 2, -v1.Y / 2, v1.Z / 2),
        Vector3.new(v1.X / 2, v1.Y / 2, -v1.Z / 2),
        Vector3.new(-v1.X / 2, -v1.Y / 2, v1.Z / 2),
        Vector3.new(-v1.X / 2, v1.Y / 2, -v1.Z / 2),
        Vector3.new(v1.X / 2, -v1.Y / 2, -v1.Z / 2),
        (Vector3.new(-v1.X / 2, -v1.Y / 2, -v1.Z / 2))
    };
    local v4 = Vector3.new(math.huge, math.huge, math.huge);
    local v5 = Vector3.new(-math.huge, -math.huge, -math.huge);
    for _, v7 in v3, nil, nil do
        local v8 = if not v2 then v0 * v7 else v0.Position + v7;
        v4 = Vector3.new(math.min(v4.X, v8.X), math.min(v4.Y, v8.Y), (math.min(v4.Z, v8.Z)));
        v5 = Vector3.new(math.max(v5.X, v8.X), math.max(v5.Y, v8.Y), (math.max(v5.Z, v8.Z)));
    end;
    return v4, v5;
end;


return function(v0, v1, v2)
    return {
        TopFront = {
            Transform = v0 * CFrame.new(0, v1.Y / 2, v1.Z / 2),
            Size = Vector3.new(v1.X + v2, v2, v2)
        },
        BottomFront = {
            Transform = v0 * CFrame.new(0, -v1.Y / 2, v1.Z / 2),
            Size = Vector3.new(v1.X + v2, v2, v2)
        },
        LeftFront = {
            Transform = v0 * CFrame.new(-v1.X / 2, 0, v1.Z / 2),
            Size = Vector3.new(v2, v1.Y + v2, v2)
        },
        RightFront = {
            Transform = v0 * CFrame.new(v1.X / 2, 0, v1.Z / 2),
            Size = Vector3.new(v2, v1.Y + v2, v2)
        },
        TopBack = {
            Transform = v0 * CFrame.new(0, v1.Y / 2, -v1.Z / 2),
            Size = Vector3.new(v1.X + v2, v2, v2)
        },
        BottomBack = {
            Transform = v0 * CFrame.new(0, -v1.Y / 2, -v1.Z / 2),
            Size = Vector3.new(v1.X + v2, v2, v2)
        },
        LeftBack = {
            Transform = v0 * CFrame.new(-v1.X / 2, 0, -v1.Z / 2),
            Size = Vector3.new(v2, v1.Y + v2, v2)
        },
        RightBack = {
            Transform = v0 * CFrame.new(v1.X / 2, 0, -v1.Z / 2),
            Size = Vector3.new(v2, v1.Y + v2, v2)
        },
        TopLeft = {
            Transform = v0 * CFrame.new(-v1.X / 2, v1.Y / 2, 0),
            Size = Vector3.new(v2, v2, v1.Z + v2)
        },
        BottomLeft = {
            Transform = v0 * CFrame.new(-v1.X / 2, -v1.Y / 2, 0),
            Size = Vector3.new(v2, v2, v1.Z + v2)
        },
        TopRight = {
            Transform = v0 * CFrame.new(v1.X / 2, v1.Y / 2, 0),
            Size = Vector3.new(v2, v2, v1.Z + v2)
        },
        BottomRight = {
            Transform = v0 * CFrame.new(v1.X / 2, -v1.Y / 2, 0),
            Size = Vector3.new(v2, v2, v1.Z + v2)
        }
    };
end;


local l_Workspace_0 = game:GetService("Workspace");
return function()
    local l_LookVector_0 = l_Workspace_0.CurrentCamera.CFrame.LookVector;
    return Vector3.new(math.round(l_LookVector_0.X), math.round(l_LookVector_0.Y), (math.round(l_LookVector_0.Z))).Unit;
end;


return function(v0, v1, v2)
    local v3 = v1 - v0;
    local l_Magnitude_0 = v3.Magnitude;
    local v5 = v2 * 0.5;
    local v6 = {};
    if v5 < l_Magnitude_0 then
        local l_Unit_0 = v3.Unit;
        l_Magnitude_0 = math.min(l_Magnitude_0, v5 * 2 + 20);
        local v8 = math.ceil(l_Magnitude_0 / v5 - 0.1);
        for v9 = 1, v8 do
            v6[v9] = v0 + (l_Unit_0 * l_Magnitude_0) * (v9 / v8);
        end;
        return v6;
    else
        v6[1] = v1;
        return v6;
    end;
end;


local l_EnumTypeIndices_0 = require(script:FindFirstAncestor("TerrainEditor").Src.Types).EnumTypeIndices;
return function(v1, v2, v3)
    local v4 = {};
    for _, v6 in l_EnumTypeIndices_0[v3], nil, nil do
        table.insert(v4, {
            Icon = if not v2 then nil else v2:get(v3, {})[v3][v6],
            Id = v6,
            Label = if not v1 then nil else v1:getText(v3, v6)
        });
    end;
    return v4;
end;


local _ = script:FindFirstAncestor("TerrainEditor");
return function(v1, v2)
    local v3 = {
        Enum.Material.Asphalt,
        Enum.Material.Basalt,
        Enum.Material.Brick,
        Enum.Material.Cobblestone,
        Enum.Material.Concrete,
        Enum.Material.CrackedLava,
        Enum.Material.Glacier,
        Enum.Material.Grass,
        Enum.Material.Ground,
        Enum.Material.Ice,
        Enum.Material.LeafyGrass,
        Enum.Material.Limestone,
        Enum.Material.Mud,
        Enum.Material.Pavement,
        Enum.Material.Rock,
        Enum.Material.Salt,
        Enum.Material.Sand,
        Enum.Material.Sandstone,
        Enum.Material.Slate,
        Enum.Material.Snow,
        Enum.Material.Water,
        Enum.Material.WoodPlanks
    };
    if v1 then
        table.insert(v3, Enum.Material.Air);
    end;
    if v2 == false then
        table.remove(v3, table.find(v3, Enum.Material.Water));
    end;
    return v3;
end;


local _ = require(script:FindFirstAncestor("TerrainEditor").Src.Types);
return function(v1)
    return {
        {
            Label = "Filename",
            Value = not v1.File and "" or v1.File.Name
        },
        {
            Label = "Dimensions",
            Value = ("%*x%*px"):format(v1.Width, v1.Height)
        }
    };
end;


return function(v0, v1, v2, v3)
    local v4 = v1:Dot(v3);
    if v4 == 0 then
        return v0, 0;
    else
        local v5 = (v2 - v0):Dot(v3) / v4;
        return v0 + v1 * v5, v5;
    end;
end;


local v0 = require(script:FindFirstAncestor("TerrainEditor").Src.Resources.Constants);
return function(v1, v2)
    local v3 = v1 / (v2 * v0.VoxelResolution);
    return (Vector3.new(math.round(v3.X), math.round(v3.Y), (math.round(v3.Z))) * v2) * v0.VoxelResolution;
end;


local v0 = require(script:FindFirstAncestor("TerrainEditor").Src.Resources.Constants);
return function(v1)
    local v2 = v1 / v0.VoxelResolution;
    return Vector3.new(math.round(v2.X), math.round(v2.Y), (math.round(v2.Z))) * v0.VoxelResolution;
end;


return function(v0, v1, v2)
    local function _(v3)
        return math.round(v3 / v2) * v2;
    end;
    local v5 = math.round((v0.Position.X - v1.X / 2) / v2) * v2;
    local v6 = math.round((v0.Position.X + v1.X / 2) / v2) * v2;
    local v7 = math.round((v0.Position.Y - v1.Y / 2) / v2) * v2;
    local v8 = math.round((v0.Position.Y + v1.Y / 2) / v2) * v2;
    local v9 = math.round((v0.Position.Z - v1.Z / 2) / v2) * v2;
    local v10 = math.round((v0.Position.Z + v1.Z / 2) / v2) * v2;
    return CFrame.new((Vector3.new((v5 + v6) / 2, (v7 + v8) / 2, (v9 + v10) / 2))), (Vector3.new(v6 - v5, v8 - v7, v10 - v9));
end;


local v0 = require(script:FindFirstAncestor("TerrainEditor").Src.Util.getBoundingBox);
local l_MaxExtents_0 = game.workspace.Terrain.MaxExtents;
local function _(v2, v3)
    local v4 = false;
    if v3.X <= v2.X then
        v4 = false;
        if v3.Y <= v3.Y then
            v4 = v3.Z <= v2.Z;
        end;
    end;
    return v4;
end;
return function(v6, v7)
    local v8, v9 = v0(v6, v7);
    local v10 = Vector3.new(l_MaxExtents_0.Min.X, l_MaxExtents_0.Min.Y, l_MaxExtents_0.Min.Z);
    local v11 = Vector3.new(l_MaxExtents_0.Max.X, l_MaxExtents_0.Max.Y, l_MaxExtents_0.Max.Z);
    local v12 = false;
    if v10.X <= v8.X then
        v12 = false;
        if v10.Y <= v10.Y then
            v12 = v10.Z <= v8.Z;
        end;
    end;
    if v12 then
        v12 = false;
        if v9.X <= v11.X then
            v12 = false;
            if v9.Y <= v9.Y then
                v12 = v9.Z <= v11.Z;
            end;
        end;
    end;
    return v12;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Src.Resources.Constants);
local _ = require(l_script_FirstAncestor_0.Src.Types);
return function(v3, v4)
    if math.abs(v3.Width / v3.Height - v4.X / v4.Z) <= v1.AspectRatioThreshold then
        return true, "";
    else
        local function v5(v6, v7)
            if v7 == 0 then
                return v6;
            else
                return (v5(v7, v6 % v7));
            end;
        end;
        local l_Width_0 = v3.Width;
        local l_Height_0 = v3.Height;
        local v10 = if l_Height_0 == 0 then l_Width_0 else v5(l_Height_0, l_Width_0 % l_Height_0);
        return false, (("%*:%*"):format(v3.Width / v10, v3.Height / v10));
    end;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Src.Resources.Constants);
local _ = require(l_script_FirstAncestor_0.Src.Types);
return function(v3, v4)
    local v5 = (v4.X / v1.VoxelResolution) / v3.Width;
    local v6 = (v4.Z / v1.VoxelResolution) / v3.Height;
    local v7 = true;
    if v5 > v1.MaxScaleFactor then
        v7 = v6 <= v1.MaxScaleFactor;
    end;
    return v7;
end;


local l_Parent_0 = script.Parent.Parent.Parent;
local v1 = require(l_Parent_0.Packages.Framework);
local v2 = require(l_Parent_0.Packages.MaterialFramework);
local l_TestHelpers_0 = v1.TestHelpers;
local l_ContextServices_0 = v1.ContextServices;
local l_MockPlugin_0 = l_TestHelpers_0.Instances.MockPlugin;
local v6 = require(l_Parent_0.Src.Resources.MakeTheme);
local v7 = require(l_Parent_0.Src.Controllers.PluginController);
local v8 = require(l_Parent_0.Src.Controllers.ShortcutController);
local v9 = require(l_Parent_0.Src.Controllers.ToolController);
local v10 = require(l_Parent_0.Src.Util.mockResourceTable);
local l_StudioServices_0 = v2.Context.StudioServices;
local v12 = {
    libraries = {
        [v2.Resources.LOCALIZATION_PROJECT_NAME] = {
            stringResourceTable = v10,
            translationResourceTable = v10
        },
        [v1.Resources.LOCALIZATION_PROJECT_NAME] = {
            stringResourceTable = v10,
            translationResourceTable = v10
        }
    }
};
local v13 = l_MockPlugin_0.new("TerrainEditor");
v13:GetMouse().UnitRay = Ray.new(Vector3.zero, Vector3.xAxis);
v13:GetMouse().X = 0;
v13:GetMouse().Y = 0;
local v14 = l_ContextServices_0.Analytics.mock();
local v15 = l_ContextServices_0.Localization.mock(v12);
local v16 = v7.mock(v13);
local v17 = v8.new(v13, v15);
local v18 = l_StudioServices_0.mock();
local v19 = v6(true);
local v20 = {
    v19,
    v14,
    v15,
    v16,
    v17,
    v18,
    (v9.mock(v16, v17, v14, v15, v19))
};
return function(v21, v22)
    assert(type(v21) == "table", "Expected story to be a table");
    return l_TestHelpers_0.provideMockContext(v22 or v20, v21);
end;


local l_Parent_0 = script.Parent.Parent.Parent;
local v1 = require(l_Parent_0.Packages.Framework);
local v2 = require(l_Parent_0.Packages.MaterialFramework);
local l_Analytics_0 = v1.ContextServices.Analytics;
local l_Localization_0 = v1.ContextServices.Localization;
local l_MockPlugin_0 = v1.TestHelpers.Instances.MockPlugin;
local v6 = require(l_Parent_0.Src.Resources.MakeTheme);
local v7 = require(l_Parent_0.Src.Controllers.PluginController);
local v8 = require(l_Parent_0.Src.Controllers.ShortcutController);
local v9 = require(l_Parent_0.Src.Controllers.ToolController);
local v10 = require(l_Parent_0.Src.Util.mockResourceTable);
local l_StudioServices_0 = v2.Context.StudioServices;
local v12 = {
    libraries = {
        [v2.Resources.LOCALIZATION_PROJECT_NAME] = {
            stringResourceTable = v10,
            translationResourceTable = v10
        },
        [v1.Resources.LOCALIZATION_PROJECT_NAME] = {
            stringResourceTable = v10,
            translationResourceTable = v10
        }
    }
};
return function()
    local v13 = l_MockPlugin_0.new("TerrainEditor");
    v13:GetMouse().UnitRay = Ray.new(Vector3.zero, Vector3.xAxis);
    v13:GetMouse().X = 0;
    v13:GetMouse().Y = 0;
    local v14 = v7.mock(v13);
    local v15 = l_Localization_0.mock(v12);
    local v16 = l_Analytics_0.mock();
    local v17 = v8.new(v13, v15);
    local v18 = v6(true);
    return {
        Analytics = v16,
        Localization = v15,
        PluginController = v14,
        ShortcutController = v17,
        StudioServices = l_StudioServices_0.mock(),
        Stylizer = v18,
        ToolController = v9.mock(v14, v17, v16, v15, v18)
    };
end;


return {
    GetTranslator = function()
        return {
            FormatByKey = function(_, v1, v2)
                local v3 = "";
                if v2 then
                    assert(typeof(v2) == "table", "Args must be a table");
                    for v4, v5 in v2, nil, nil do
                        v3 = ("%*,%*:%*"):format(v3, v4, v5);
                    end;
                    v3 = string.sub(v3, 2);
                end;
                return (("%*:[%*]"):format(v1, v3));
            end
        };
    end
};


return {
    testMatch = {
        "**/*.spec"
    },
    testTimeout = 60000
};


game:DefineFastFlag("TerrainToolsImportUploadAssets", false);
game:DefineFastFlag("TerrainSmoothToolFix", false);
game:DefineFastFlag("TerrainEditorFixQuickWait", false);
game:DefineFastFlag("TerrainEditorUseTerrainChannels", false);
game:DefineFastFlag("ShorelinesRemoveDialog", false);
game:DefineFastFlag("TerrainToolsPaintToolFix", false);
return nil;


return function(v0, v1)
    if v0 then
        local l_Parent_0 = script.Parent.Parent;
        local _ = game:GetFastFlag("TerrainToolsImportUploadAssets");
        local l_TerrainEditorOverhaul_0 = game:GetFastFlag("TerrainEditorOverhaul");
        local l_Shorelines_Tooling_0 = game:GetFastFlag("Shorelines_Tooling");
        local l_SmoothVoxels_Tooling_0 = game:GetFastFlag("SmoothVoxels_Tooling");
        local v7 = require(l_Parent_0.Packages.Framework);
        local v8 = require(l_Parent_0.Packages.Roact);
        local v9 = require(l_Parent_0.Packages.Rodux);
        local l_ContextServices_0 = v7.ContextServices;
        local l_Analytics_0 = l_ContextServices_0.Analytics;
        local l_Mouse_0 = l_ContextServices_0.Mouse;
        local l_Store_0 = l_ContextServices_0.Store;
        local l_Localization_0 = l_ContextServices_0.Localization;
        local v15 = require(l_Parent_0.Src.ContextItems);
        local v16 = require(l_Parent_0.Src.Util.createAnalyticsHandlers);
        local _ = v7.Http;
        local v18 = require(l_Parent_0.Src.Reducers.MainReducer);
        local v19 = require(l_Parent_0.Src.Resources.PluginTheme);
        local v20 = require(l_Parent_0.Src.Resources.makeTheme);
        local l_SourceStrings_0 = l_Parent_0.Src.Resources.SourceStrings;
        local l_LocalizedStrings_0 = l_Parent_0.Src.Resources.LocalizedStrings;
        local v23 = require(l_Parent_0.Src.Util.PluginActionsController);
        local v24 = require(l_Parent_0.Src.Util.PluginActivationController);
        local v25 = require(l_Parent_0.Src.TerrainInterfaces.TerrainImporterInstance);
        local v26 = require(l_Parent_0.Src.TerrainInterfaces.TerrainGenerationInstance);
        local v27 = require(l_Parent_0.Src.TerrainInterfaces.TerrainSeaLevel);
        local v28 = require(l_Parent_0.Src.Util.ImageLoader);
        local v29 = require(l_Parent_0.Src.Components.TerrainTools);
        local function v49()
            local v30 = l_ContextServices_0.Plugin.new(v0);
            local v31 = l_Mouse_0.new(v0:getMouse());
            local v32 = v9.Store.new(v18, nil, {});
            local v33 = l_Store_0.new(v32);
            local v34 = v15.DEPRECATED_Theme.new(v19.new());
            local v35 = l_Localization_0.new({
                pluginName = "TerrainToolsV2",
                stringResourceTable = l_SourceStrings_0,
                translationResourceTable = l_LocalizedStrings_0
            });
            local v36 = v23.new(v0, {
                EditPlane = {
                    allowBinding = false,
                    defaultShortcut = "ctrl+shift+space",
                    id = "EditPlane",
                    statusTip = v35:getText("EditPlaneAction", "StatusTip"),
                    text = v35:getText("EditPlaneAction", "Text")
                },
                CopySelected = if not l_TerrainEditorOverhaul_0 then nil else {
                    allowBinding = false,
                    defaultShortcut = "ctrl+c",
                    id = "CopySelected",
                    statusTip = v35:getText("SelectionAction", "CopyStatusTip"),
                    text = v35:getText("SelectionAction", "CopyText")
                },
                CutSelected = if not l_TerrainEditorOverhaul_0 then nil else {
                    allowBinding = false,
                    defaultShortcut = "ctrl+x",
                    id = "CutSelected",
                    statusTip = v35:getText("SelectionAction", "CutStatusTip"),
                    text = v35:getText("SelectionAction", "CutText")
                },
                DeleteSelected = if not l_TerrainEditorOverhaul_0 then nil else {
                    allowBinding = false,
                    defaultShortcut = "delete",
                    id = "DeleteSelected",
                    statusTip = v35:getText("SelectionAction", "DeleteStatusTip"),
                    text = v35:getText("SelectionAction", "DeleteText")
                },
                PasteSelected = if not l_TerrainEditorOverhaul_0 then nil else {
                    allowBinding = false,
                    defaultShortcut = "ctrl+v",
                    id = "PasteSelected",
                    statusTip = v35:getText("SelectionAction", "PasteStatusTip"),
                    text = v35:getText("SelectionAction", "PasteText")
                },
                DuplicateSelected = if not l_TerrainEditorOverhaul_0 then nil else {
                    allowBinding = false,
                    defaultShortcut = "ctrl+d",
                    id = "DuplicateSelected",
                    statusTip = v35:getText("SelectionAction", "DuplicateStatusTip"),
                    text = v35:getText("SelectionAction", "DuplicateText")
                },
                Apply = if not l_TerrainEditorOverhaul_0 then nil else {
                    allowBinding = false,
                    defaultShortcut = "return",
                    id = "Apply",
                    statusTip = v35:getText("TransformAction", "ApplyStatusTip"),
                    text = v35:getText("TransformAction", "ApplyText")
                },
                Cancel = if not l_TerrainEditorOverhaul_0 then nil else {
                    allowBinding = false,
                    defaultShortcut = "escape",
                    id = "Quit",
                    statusTip = v35:getText("TransformAction", "CancelStatusTip"),
                    text = v35:getText("TransformAction", "CancelText")
                }
            });
            local v37 = l_Analytics_0.new(v16);
            local v38 = require(l_Parent_0.Src.Util.getTerrain)();
            local v39 = v15.Terrain.new(v38);
            local v40 = v24.new(v0);
            local v41 = v25.new({
                localization = v35,
                analytics = v37
            });
            local v42 = v26.new({
                terrain = v38,
                localization = v35,
                analytics = v37
            });
            local v43 = v27.new({
                terrain = v38,
                localization = v35
            });
            local v44 = v20();
            local v45 = v28.new();
            local v46 = v15.CalloutController.new();
            v46:defineCallout("TerrainToolsColormapCallout", v35:getText("ColormapCallout", "Title"), v35:getText("ColormapCallout", "Description"), "https://developer.roblox.com/en-us/articles/importing-terrain-data");
            v46:defineCallout("TerrainToolsLiveEditCallout", v35:getText("LiveEditCallout", "Title"), v35:getText("LiveEditCallout", "Description"), "https://devforum.roblox.com/t/improvements-to-the-terrain-editor/2344311");
            v46:defineCallout("TerrainToolsFillCallout", v35:getText("FillCallout", "Title"), v35:getText("FillCallout", "Description"), "https://devforum.roblox.com/t/improvements-to-the-terrain-editor/2344311");
            local v47 = nil;
            if l_Shorelines_Tooling_0 then
                v47 = v15.ShorelineController.new(v37, v0, v32, v39);
            end;
            local v48 = nil;
            if l_SmoothVoxels_Tooling_0 then
                v48 = v15.SmoothVoxelsController.new(v37, v0, v32, v39);
            end;
            return {
                plugin = v30,
                mouse = v31,
                store = v33,
                theme = v34,
                devFrameworkThemeItem = v44,
                localization = v35,
                analytics = v37,
                imageLoader = v45,
                terrain = v39,
                pluginActivationController = v40,
                pluginActionsController = v36,
                terrainImporter = v41,
                terrainGeneration = v42,
                seaLevel = v43,
                calloutController = v46,
                shorelineController = v47,
                smoothVoxelsController = v48
            };
        end;
        local function v53(v50)
            for _, v52 in pairs(v50) do
                pcall(function()
                    v52:destroy();
                end);
            end;
        end;
        (function()
            local v54 = v49();
            v54.pluginLoaderContext = v1;
            local v55 = v8.mount(v8.createElement(v29, v54));
            local v56 = nil;
            local l_status_0, l_result_0 = pcall(function()
                return game:GetService("StudioService"):HasInternalPermission();
            end);
            if not (not l_status_0 or not l_result_0) then
                v7.DeveloperTools.forPlugin("Terrain Editor", v0):addRoactTree("Roact tree", v55, v8);
            end;
            v0.Unloading:Connect(function()
                if v55 then
                    v8.unmount(v55);
                    v55 = nil;
                end;
                if v56 then
                    v56:destroy();
                    v56 = nil;
                end;
                v53(v54);
            end);
        end)();
        return ;
    else
        return ;
    end;
end;


return require(script.Parent.Action)(script.Name, function(v0, v1)
    assert(type(v0) == "string", ("Expected toolName to be a string, received %s"):format((type(v0))));
    assert(type(v1) == "table", ("Expected toolAction to be a table, received %s"):format((type(v1))));
    return {
        toolName = v0,
        toolAction = v1
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    local v1 = tonumber(v0);
    assert(v1, ("Expected baseSize to be a number, received %s"):format((type(v0))));
    return {
        baseSize = v1
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    local v1 = tonumber(v0);
    assert(v1, ("Expected height to be a number, received %s"):format((type(v0))));
    return {
        height = v1
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "string", ("Expected pivot to be a string, received %s"):format((type(v0))));
    return {
        pivot = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    local v1 = tonumber(v0);
    assert(v1, ("Expected planePositionY to be a number, received %s"):format((type(v0))));
    return {
        planePositionY = v1
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "table", ("Expected position to be a table, received %s"):format((type(v0))));
    local v1 = tonumber(v0.X);
    local v2 = tonumber(v0.Y);
    local v3 = tonumber(v0.Z);
    assert(v1, ("Expected position.X to be a number, received %s"):format((type(v0.x))));
    assert(v2, ("Expected position.Y to be a number, received %s"):format((type(v0.y))));
    assert(v3, ("Expected position.Z to be a number, received %s"):format((type(v0.z))));
    return {
        position = {
            X = v1,
            Y = v2,
            Z = v3
        }
    };
end);


return require(script.Parent.Action)(script.Name, function(v0, v1)
    return {
        selectionTransform = v0,
        selectionSize = v1
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "table", ("Expected size to be a table, received %s"):format((type(v0))));
    local v1 = tonumber(v0.X);
    local v2 = tonumber(v0.Y);
    local v3 = tonumber(v0.Z);
    assert(v1, ("Expected size.X to be a number, received %s"):format((type(v0.x))));
    assert(v2, ("Expected size.Y to be a number, received %s"):format((type(v0.y))));
    assert(v3, ("Expected size.Z to be a number, received %s"):format((type(v0.z))));
    return {
        size = {
            X = v1,
            Y = v2,
            Z = v3
        }
    };
end);


return require(script.Parent.Action)(script.Name, function(v0, v1)
    return {
        sourceTransform = v0,
        sourceSize = v1
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    local v1 = tonumber(v0);
    assert(v1, ("Expected strength to be a number, received %s"):format((type(v0))));
    return {
        strength = v1
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "string", ("Expected tabName to be a string, received %s"):format((type(v0))));
    return {
        tabName = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0, v1)
    return {
        targetTransform = v0,
        targetSize = v1
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "string", ("Expected currentTool to be a string, received %s"):format((type(v0))));
    return {
        currentTool = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "string", ("Expected brushShape to be a string, received %s"):format((type(v0))));
    return {
        brushShape = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "string", ("Expected flattenMode to be a string, received %s"):format((type(v0))));
    return {
        flattenMode = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    return {
        colormap = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    return {
        heightmap = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "boolean", ("Expected autoMaterial to be a boolean, received %s"):format((type(v0))));
    return {
        autoMaterial = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "boolean", ("Expected locked to be a boolean, received %s"):format((type(v0))));
    return {
        locked = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0, v1)
    assert(type(v0) == "string", ("Expected biome to be a string, received %s"):format((type(v0))));
    assert(type(v1) == "boolean", ("Expected value to be a boolean, received %s"):format((type(v1))));
    return {
        newBiomeUpdate = {
            [v0] = v1
        }
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    local v1 = tonumber(v0);
    assert(v1, ("Expected biomeSize to be a number, received %s"):format((type(v0))));
    return {
        biomeSize = v1
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(typeof(v0) == "string", ("Expected BrushMode to be a string, received %s"):format((typeof(v0))));
    return {
        brushMode = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    return {
        colormapWarningId = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(typeof(v0) == "EnumItem", ("Expected defaultMaterial to be a EnumItem, received %s"):format((typeof(v0))));
    return {
        defaultMaterial = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "boolean", ("Expected editPlaneMode to be a boolean, received %s"):format((type(v0))));
    return {
        editPlaneMode = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "boolean", ("Expected fixedPlane to be a boolean, received %s"):format((type(v0))));
    return {
        fixedPlane = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "boolean", ("Expected haveCaves to be a boolean, received %s"):format((type(v0))));
    return {
        haveCaves = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "boolean", ("Expected heightPicker to be a boolean, received %s"):format((type(v0))));
    return {
        heightPicker = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "boolean", ("Expected ignoreParts to be a boolean, received %s"):format((type(v0))));
    return {
        ignoreParts = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "boolean", ("Expected ignoreWater to be a boolean, received %s"):format((type(v0))));
    return {
        ignoreWater = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "string", ("Expected materialMode to be a string, received %s"):format((type(v0))));
    return {
        materialMode = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "boolean", ("Expected liveEdit to be a boolean, received %s"):format((type(v0))));
    return {
        liveEdit = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(typeof(v0) == "EnumItem", ("Expected material to be a EnumItem, received %s"):format((typeof(v0))));
    return {
        material = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "boolean", ("Expected mergeEmpty to be a boolean, received %s"):format((type(v0))));
    return {
        mergeEmpty = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    local v1 = true;
    if tostring(v0) ~= "Cryo.None" then
        v1 = true;
        if typeof(v0) ~= "CFrame" then
            v1 = not v0;
        end;
    end;
    assert(v1);
    return {
        planeCFrame = v0
    };
end);


local v0 = require(script.Parent.Action);
local _ = require(script.Parent.Parent.Parent.Src.Util.TerrainEnums).PlaneLockType;
return v0(script.Name, function(v2)
    assert(type(v2) == "string", ("Expected planeLock to be a string, received %s"):format((type(v2))));
    return {
        planeLock = v2
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "boolean", ("Expected planeLockActive to be a boolean, received %s"):format((type(v0))));
    return {
        planeLockActive = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "boolean", ("Expected snapToVoxels to be a boolean, received %s"):format((type(v0))));
    return {
        replaceMaterial = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "string", ("Expected ReplaceMode to be a string, received %s"):format((type(v0))));
    return {
        ReplaceMode = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "string", ("Expected seed to be a string, received %s"):format((type(v0))));
    return {
        seed = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "number", ("Expected material to be a number, received %s"):format((type(v0))));
    return {
        shorelinesUpgradePercent = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "boolean", ("Expected material to be a boolean, received %s"):format((type(v0))));
    return {
        shorelinesUpgradePossible = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "boolean", ("Expected material to be a boolean, received %s"):format((type(v0))));
    return {
        shorelinesUpgradeSuggestion = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "boolean", ("Expected sizeChangedByUser to be a boolean, received %s"):format((type(v0))));
    return {
        sizeChangedByUser = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "number", ("Expected material to be a number, received %s"):format((type(v0))));
    return {
        smoothVoxelsUpgradePercent = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "boolean", ("Expected material to be a boolean, received %s"):format((type(v0))));
    return {
        smoothVoxelsUpgradePossible = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "boolean", ("Expected material to be a boolean, received %s"):format((type(v0))));
    return {
        smoothVoxelsUpgradeSuggestion = v0
    };
end);


return require(script.Parent.Action)(script.Name, function(v0)
    assert(type(v0) == "boolean", ("Expected snapToVoxels to be a boolean, received %s"):format((type(v0))));
    return {
        snapToVoxels = v0
    };
end);